简体   繁体   English

icefaces selectinputdate值

[英]icefaces selectinputdate value

I use iceface's selectInputDate. 我使用iceface的selectInputDate。 The code in .jspx file is the following: .jspx文件中的代码如下:

<ice:selectInputDate id="Dt" 
        value="#{actionsBean.MDate}"
        renderAsPopup="true" required="true"
        partialSubmit = "true"
        popupDateFormat="#{msgs.date_format}" 
        valueChangeListener = "#{actionsBean.mDateChangeListener}">
                          <f:converter converterId="MDateConverter" />      </ice:selectInputDate>

The problem actually is: I want that value in input was empty string by default. 问题实际上是:我希望输入中的值默认为空字符串。 I set to MDate null value, then panel opens and after user(me in this case) worked and closed panel I set null value to MDate again. 我设置为MDate空值,然后打开面板,在用户(在本例中为me)工作并关闭面板后,我再次将空值设置为MDate。 But then I open the panel one more time the last value I selected via calendar was saved and automatically filled in. How can I resolve this?thanks. 但是随后我又一次打开面板,最后一次保存通过日历选择的值并自动填写。我该如何解决呢?谢谢。

When you close the panel, your selectInputDate component doesn't redraw on the page, and then returns the old value. 关闭面板时,您的selectInputDate组件不会在页面上重绘,然后返回旧值。 It can be, for example, if you use 'rendered=true/false' property for showing/hiding of the parent panel. 例如,如果您使用“ rendered = true / false”属性来显示/隐藏父面板,则可能是这种情况。

For fix, use 'visibled' property instead of 'rendered' or use binding for clear value in your selectInputDate component directly 要进行修复,请使用“ visibled”属性而不是“ rendered”,或直接在您的selectInputDate组件中使用绑定获取清晰的值

You may actually replace the valueChangeListener with f:ajax listener and try to see the difference. 您实际上可以使用f:ajax侦听器替换valueChangeListener ,然后尝试查看区别。

<h:form id="dateForm">
....
<ice:selectInputDate id="Dt" 
    value="#{actionsBean.MDate}"
    renderAsPopup="true" required="true"
    partialSubmit = "true"
    popupDateFormat="#{msgs.date_format}">
        <f:converter converterId="MDateConverter" />      
        <f:ajax execute="@this" render="@form" 
              listener = "#{actionsBean.mDateChangeListener}">
</ice:selectInputDate>
...
</h:form>

This is probably caused by an issue with the icefaces popup panel, what I tried is executing this code each time the popup is closed (hidden) :: 这可能是由于icefaces弹出面板的问题引起的,我尝试在每次关闭(隐藏)弹出窗口时都执行此代码::

public void clearSubmittedValues() {
    final FacesContext context = FacesContext.getCurrentInstance();
    final Application application = context.getApplication();
    final ViewHandler viewHandler = application.getViewHandler();
    final UIViewRoot viewRoot = viewHandler.createView(context, context.getViewRoot().getViewId());
    context.setViewRoot(viewRoot);
}

This will reset the popup's state. 这将重置弹出窗口的状态。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM