-
1. Re: Help! Very BASIC JSF question!!
timgozag Aug 24, 2009 12:57 PM (in response to dmitri.ilyin)It is not simple as you thought. a4j reRender will not work because it is only rerender the form in your modal panel, but values in your bean are still there.
There are two options I think:
1. Easy way: have a cancel button instead of a reset button in your modal. When click on Cancel (use immediate=true to pass the validation), it will trigger a cancel function in your backing bean then clear out all the UIComponent of that form (get it from FaceContext). So when users open the modal Panel again, you just reRender the modal's form and all your initial values will be there.
2. Keep the reset button but you have to clear all the component's value then reset them. -
2. Re: Help! Very BASIC JSF question!!
dmitri.ilyin Aug 24, 2009 1:20 PM (in response to dmitri.ilyin)The explicit clear the values is exactly what i wanted to avoid.
I have several modal dialogs with diferent input fields of diferent types and ids. So i would have to make this "manual clear" each time. -
3. Re: Help! Very BASIC JSF question!!
asingla4 Aug 24, 2009 2:42 PM (in response to dmitri.ilyin)Hi,
I have faced a similar kind of problem in my earlier project.
What I did,
When I click the reset button, I disabled all the fields through javascript and submit the page to an empty method. When i come back, everything is clear.
:))
Though just a hack, it works and is less tedious.
Akash.
thedaedals.com/ -
4. Re: Help! Very BASIC JSF question!!
asingla4 Aug 24, 2009 2:44 PM (in response to dmitri.ilyin)"asingla4" wrote:
Hi,
I have faced a similar kind of problem in my earlier project.
What I did,
When I click the reset button, I disabled all the fields through javascript and submit the page to an empty method. When i come back, everything is clear.
:))
Though just a hack, it works and is less tedious.
Akash.
http://www.thedaedals.com/ -
6. Re: Help! Very BASIC JSF question!!
dmitri.ilyin Aug 25, 2009 11:22 AM (in response to dmitri.ilyin)thanks for the tips.
@asingla4: Could you provide you JavaScript code pls? Is it generic or you have hard coded you input field in it?
The Ilya's approach seems to be a less hack for me. :) BUT it does not solve my problem completely. Becouse avoiding submmited values don't clear the already set local values.
My scenario:
i have two input fields -> i fill both of them -> first field input will be validated and validation fails -> second field gets locaValue -> now i call method with a4j:region button, to avoid submiting any values in the form -> first field gets value from EL (fine) -> second field shows localValue (it was inialized in previous call).
It seems to me the only solution is to reset the local values manualy.
What i would need is a TAG just like <a4j:region>, that will reset local values of all input fields found within it before render response phase. It could be generic enough for my scenario... -
7. Re: Help! Very BASIC JSF question!!
nbelaevski Aug 25, 2009 7:26 PM (in response to dmitri.ilyin)Hi,
Please consider this example:<h:form> <rich:messages /> <a4j:outputPanel id="box"> <h:inputText value="#{forum5Bean.text}"> <f:validateLength minimum="3" /> </h:inputText> <h:inputText value="#{forum5Bean.text2}"> <f:validateLength minimum="3" /> </h:inputText> <a4j:commandLink value="Apply" />Â <a4j:commandLink value="Reset" ajaxSingle="true" reRender="box" actionListener="#{forum5Bean.resetValues}" /> </a4j:outputPanel> </h:form>
public void resetValues(ActionEvent actionEvent) { UIComponent component = actionEvent.getComponent(); Iterator<UIComponent> children = component.getParent().getChildren().iterator(); while (children.hasNext()) { UIComponent child = children.next(); if (child != component) { children.remove(); } } this.text = "text"; this.text2 = "text2"; }
The idea behind this is that you can remove just a subtree of component tree - view handler will build it for you then, but without any saved values. -
8. Re: Help! Very BASIC JSF question!!
m.a.g Aug 26, 2009 2:01 AM (in response to dmitri.ilyin)See the related bug - https://jira.jboss.org/jira/browse/RF-7136
-
9. Re: Help! Very BASIC JSF question!!
dmitri.ilyin Aug 26, 2009 6:20 AM (in response to dmitri.ilyin)Hi,
i think the nick's solution is mostly generic. I will use it.
thanks a lot!