You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Jeffrey Porter <PO...@WMGMAIL.wmg.warwick.ac.uk> on 2005/10/12 17:42:06 UTC

one button 2 forms... how?

 

Hello all,

 

I'm a little stuck & need some guidance.

 

I have a web page with 2 forms on it. (Bean01 & Bean02).

I want to be able to have the user click a button and then behind the
scenes take the data from these 2 beans and persist it.

I'm not sure how to do this & require someone pointing me in right
direction.

 

Example of what I'm trying... (I know this wont work, I'd like to know
what I should do)

 

<h:form>

 

<h:form id="form1" name="formBean01">

      <h:inputText id="name01" value="01" maxlength="10" size="15"
required="true" />

      </h:form>

 

      <h:form id="form2" name="formBean02">

      <h:inputText id="name02" value="02" maxlength="10" size="15"
required="true" />

      </h:form>

 

                  

      <h:commandButton value="Create"
action="#{taskMangerBean.saveBeans}"/>

</h:form>

 

 

   public String saveBeans() {

        FacesContext facesContext = FacesContext.getCurrentInstance();

        VariableResolver vr =
facesContext.getApplication().getVariableResolver();

        

        Bean01 bean01 = (Bean01) vr.resolveVariable(facesContext,
"bean01");

        Bean02 bean02 = (Bean02) vr.resolveVariable(facesContext,
"bean02");

        

        //insert any bus logic here

        return ("sucesss");

    }

 

 

 

Thanks 

Jeff


Re: one button 2 forms... how?

Posted by "ir. ing. Jan Dockx" <ja...@mac.com>.
You can't nest forms. Just remove the nested form definitions. You're 
done.

On 12 Oct 2005, at 17:42, Jeffrey Porter wrote:

>  
> Hello all,
>  
> I’m a little stuck & need some guidance.
>  
> I have a web page with 2 forms on it. (Bean01 & Bean02).
> I want to be able to have the user click a button and then behind the 
> scenes take the data from these 2 beans and persist it.
> I’m not sure how to do this & require someone pointing me in right 
> direction.
>  
> Example of what I’m trying… (I know this wont work, I’d like to know 
> what I should do)
>  
> <h:form>
>  
> <h:form id="form1" name="formBean01">
>       <h:inputText id="name01" value="01" maxlength="10" size="15" 
> required="true" />
>       </h:form>
>  
>       <h:form id="form2" name="formBean02">
>       <h:inputText id="name02" value="02" maxlength="10" size="15" 
> required="true" />
>       </h:form>
>  
>                  
>       <h:commandButton value="Create" 
> action="#{taskMangerBean.saveBeans}"/>
> </h:form>
>  
>  
>    public String saveBeans() {
>         FacesContext facesContext = FacesContext.getCurrentInstance();
>         VariableResolver vr = 
> facesContext.getApplication().getVariableResolver();
>        
>         Bean01 bean01 = (Bean01) vr.resolveVariable(facesContext, 
> "bean01");
>         Bean02 bean02 = (Bean02) vr.resolveVariable(facesContext, 
> "bean02");
>        
>         //insert any bus logic here
>         return ("sucesss");
>     }
>  
>  
>  
> Thanks
> Jeff
>
Met vriendelijke groeten,

Jan Dockx

PeopleWare NV - Head Office
Cdt.Weynsstraat 85
B-2660 Hoboken
Tel: +32 3 448.33.38
Fax: +32 3 448.32.66

PeopleWare NV - Branch Office Geel
Kleinhoefstraat 5
B-2440 Geel
Tel: +32 14 57.00.90
Fax: +32 14 58.13.25

http://www.peopleware.be/
http://www.mobileware.be/