'How to set a blank default value in iceface's selectinputdate?
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?
Solution 1:[1]
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
Solution 2:[2]
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.
Solution 3:[3]
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>
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Maxim Sharai |
| Solution 2 | R?zvan Petruescu |
| Solution 3 |
