p:pickList验证失败后无法填充数据

p:pickList验证失败后无法填充数据

问题描述:
在一个dialog里有input和pickList;input里填入非法数据后,提交表单,验证失败;立刻关闭dialog,重新打开它,发现pickList无法填充数据。

同样问题已经出现在 stackoverflow, 目前已在官方论坛提问解决办法还未得到有效回答。

URL: here

下面是我做出的解决办法,虽然有点丑陋:
This is an old question, but I also encountered this issue recently, and now being helpless. Let's see the p:pickList:

<td>
    <p:pickList id="customersList" iconOnly="true"
                value="#{addEditUserController.customersList}" var="customer"
                itemValue="#{customer.value}" itemLabel="#{customer.label}"/>
</td>

We know the [var="customer"] is an iterator, but when validation error happens, this var is assigned to String type, it's odd. When you close this popup then re-populate it again, you will get an error, messages like this: no property label(value) on type of String... the customer var now is a String, so it has no value nor label property.

For now, I use a tricky way, it won't work out always, it depends on your code: Assume that the value and label are unique, set customersList type of List String, customersList binds the label, find the value of the label when submit at the backend; Why this way can avoid re-populate exception, that's because the iterator is always type of String, no matter validation error occurs or not.

Hope this can help the need.

转载于:https://my.oschina.net/placeholder/blog/168076

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值