You are viewing a plain text version of this content. The canonical link for it is here.
Posted to adffaces-user@incubator.apache.org by Jochen Traunecker <ma...@yahoo.com> on 2007/03/22 09:53:13 UTC

[TRINIDAD] How to reset a form

Hello everybody,

using Trinidad and Shale I ran into this silly simple problem: I want a form containing a bunch of text-input fields, each of them with some validator associated to get reset by clicking a commandButton. To avoid validating the input fields I use immediate="true" for the reset button. My model gets reset (see pseudocode) but the textfields in the browser don't disply the model-values - they keep their values. I'm wondering, how to reset some UIComponents (without any validation). I thougth, that all updates to the datamodel/backingbean before RENDER_RESPONSE will have an impact on the rendered output, regardless of immediate="true". Is this a partialPageRendering issue ?


Thanks for your help! 
Jochen

Pseudocode


<tr:form>
    <tr:panelPage>
        <tr:panelHorizontalLayout ...>
            <tr:treeTable>...</tr:treeTable>
          <tr:switcher facetName="...">
               <tr:facet name="a"> ...</tr:facet>
                <tr:facet name="b">
                   <tr:panelFormLayout>
                        <tr:inputText id="name"> <f:validateLength .../></inputText>
                        <tr:inputText id="street"> <f:validateLength .../></inputText>
                        <tr:commandButton text="save" action="#{backingbean.save}"/>
                        <tr:commandButton text="reset" action="#{backingbean.reset}" immediate="true"/>
                </tr:panelFormLayout>
                </tr:facet>
           </tr:switcher>
        </tr:panelHorizontalLayout>
   </tr:panelPage>
</tr:form>



backingbean.class

String name="Foo";

public String save(){
    //getName is set to validated name provided by the user
    someDao.persist(getName());
}

public String reset(){
    //do nothing, as prerender will reset the model
}
...
public void prerender(){
   name=someDao.retrieve(); //allways reset datamodel to latest persistent state
}

public String getName(){
    return name;
}

public void setName(String name){
    this.name= name;
}




		
___________________________________________________________ 
Telefonate ohne weitere Kosten vom PC zum PC: http://messenger.yahoo.de

Re: [TRINIDAD] How to reset a form

Posted by Matthias Wessendorf <ma...@apache.org>.
have you also tried to call resetValue() on UIXeditablevalue?

-M

On 3/22/07, Jochen Traunecker <ma...@yahoo.com> wrote:
> Hello everybody,
>
> using Trinidad and Shale I ran into this silly simple problem: I want a form containing a bunch of text-input fields, each of them with some validator associated to get reset by clicking a commandButton. To avoid validating the input fields I use immediate="true" for the reset button. My model gets reset (see pseudocode) but the textfields in the browser don't disply the model-values - they keep their values. I'm wondering, how to reset some UIComponents (without any validation). I thougth, that all updates to the datamodel/backingbean before RENDER_RESPONSE will have an impact on the rendered output, regardless of immediate="true". Is this a partialPageRendering issue ?
>
>
> Thanks for your help!
> Jochen
>
> Pseudocode
>
>
> <tr:form>
>     <tr:panelPage>
>         <tr:panelHorizontalLayout ...>
>             <tr:treeTable>...</tr:treeTable>
>           <tr:switcher facetName="...">
>                <tr:facet name="a"> ...</tr:facet>
>                 <tr:facet name="b">
>                    <tr:panelFormLayout>
>                         <tr:inputText id="name"> <f:validateLength .../></inputText>
>                         <tr:inputText id="street"> <f:validateLength .../></inputText>
>                         <tr:commandButton text="save" action="#{backingbean.save}"/>
>                         <tr:commandButton text="reset" action="#{backingbean.reset}" immediate="true"/>
>                 </tr:panelFormLayout>
>                 </tr:facet>
>            </tr:switcher>
>         </tr:panelHorizontalLayout>
>    </tr:panelPage>
> </tr:form>
>
>
>
> backingbean.class
>
> String name="Foo";
>
> public String save(){
>     //getName is set to validated name provided by the user
>     someDao.persist(getName());
> }
>
> public String reset(){
>     //do nothing, as prerender will reset the model
> }
> ...
> public void prerender(){
>    name=someDao.retrieve(); //allways reset datamodel to latest persistent state
> }
>
> public String getName(){
>     return name;
> }
>
> public void setName(String name){
>     this.name= name;
> }
>
>
>
>
>
> ___________________________________________________________
> Telefonate ohne weitere Kosten vom PC zum PC: http://messenger.yahoo.de
>


-- 
Matthias Wessendorf
http://tinyurl.com/fmywh

further stuff:
blog: http://jroller.com/page/mwessendorf
mail: mwessendorf-at-gmail-dot-com