سؤال

I use Icefaces' selectInputDate. The code in .jspx file is the following:

<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 the input to be an 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. 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?

هل كانت مفيدة؟

المحلول

When you close the panel, your selectInputDate component doesn't redraw on the page, and then returns the old value. It can be, for example, if you use 'rendered=true/false' property for showing/hiding of the parent panel.

For fix, use 'visibled' property instead of 'rendered' or use binding for clear value in your selectInputDate component directly

نصائح أخرى

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) ::

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.

You may actually replace the valueChangeListener with f:ajax listener and try to see the difference.

<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>
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top