You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Ma...@virginmoney.com on 2007/06/29 14:49:14 UTC

Struts 2.0 form bean

Hi All,

As there is no concept of Action form beans in struts 2.0 we have to define
the field attributes in the Action class.

I am using the same action class for two form submission, is there any way
of configuring form beans to this actions.

For example  if  my first form has fields name, address, sex and second
form has  company, salary.
I am using the same action class for the above form submission i.e.
processPersonalDetails()  and processEmplymentDetails()
is there any way of defining this fields attribute in two separate bean
classes and configure with the appropriate action.?

Thanks,
Manoj.


This e-mail is intended to be confidential to the recipient. If you receive a copy in error, please inform the sender and then delete this message. Virgin Money do not accept responsibility for changes made to any e-mail after sending. Virgin Money have swept, and believe this e-mail to be free of viruses and profanity but make no guarantees to this effect.

Virgin Money Personal Financial Service Ltd is authorised and regulated by the Financial Services Authority. Registered in England no. 3072766. Entered on the Financial Services Authority's Register http://www.fsa.gov.uk/register/. Register Number 179271. The Virgin Deposit Account is a personal bank account with The Royal Bank of Scotland.

Virgin Money Unit Trust Managers Ltd is authorised and regulated by the Financial Services Authority. Registered in England no. 3000482. Entered on the Financial Services Authority's Register. Register Number 171748.

Virgin Money Ltd. Registered in England no. 4232392. Introducer appointed representative only of Virgin Money Personal Financial Service Ltd.

Virgin Money Management Services Ltd. Registered in England no.3072772.

Virgin Money Group Ltd. Registered in England no.3087587.

All the above companies have their Registered office at Discovery House, Whiting Road, Norwich NR4 6EJ. 

All products are open only to residents of the United Kingdom.

This message has been checked for viruses and spam by the Virgin Money email scanning system powered by Messagelabs.

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Struts 2.0 form bean

Posted by Ma...@virginmoney.com.
Thanks David it worked...




                                                                           
             Dave Newton                                                   
             <newton.dave@yaho                                             
             o.com>                                                     To 
                                       Struts Users Mailing List           
             29/06/2007 14:51          <us...@struts.apache.org>            
                                                                        cc 
                                                                           
             Please respond to                                     Subject 
               "Struts Users           Re: Struts 2.0 form bean            
               Mailing List"                                               
             <user@struts.apac                                             
                  he.org>                                                  
                                                                           
                                                                           
                                                                           




--- Manoj.Gupta@virginmoney.com wrote:
> In the action class i defined a attribute called
>
>     public PersonalDetailForm getForm() {
>         return form;
>     }
>
>     public void setForm(PersonalDetailForm form) {
>         this.form = form;
>     }
>
>     PersonalDetailForm form;
>
>
> and the jsp looks like
> <s:form action="doPersonal" method="POST"
> name="form">
>     <s:actionerror />
>     <s:fielderror />
>     <s:textfield name="name" label="Name" />  <br/>
>     <s:textfield name="dob" label="Date of birth" />

How would S2 know what "name" belonged to if you
didn't say "form.name" ?

Personally I think you're going about the problem the
wrong way; I'd think less in terms of S1.

d.




____________________________________________________________________________________

Moody friends. Drama queens. Your life? Nope! - their life, your story.
Play Sims Stories at Yahoo! Games.
http://sims.yahoo.com/

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


This message has been checked for viruses and spam by the Virgin Money
email scanning system powered by Messagelabs.






This e-mail is intended to be confidential to the recipient. If you receive a copy in error, please inform the sender and then delete this message. Virgin Money do not accept responsibility for changes made to any e-mail after sending. Virgin Money have swept, and believe this e-mail to be free of viruses and profanity but make no guarantees to this effect.

Virgin Money Personal Financial Service Ltd is authorised and regulated by the Financial Services Authority. Registered in England no. 3072766. Entered on the Financial Services Authority's Register http://www.fsa.gov.uk/register/. Register Number 179271. The Virgin Deposit Account is a personal bank account with The Royal Bank of Scotland.

Virgin Money Unit Trust Managers Ltd is authorised and regulated by the Financial Services Authority. Registered in England no. 3000482. Entered on the Financial Services Authority's Register. Register Number 171748.

Virgin Money Ltd. Registered in England no. 4232392. Introducer appointed representative only of Virgin Money Personal Financial Service Ltd.

Virgin Money Management Services Ltd. Registered in England no.3072772.

Virgin Money Group Ltd. Registered in England no.3087587.

All the above companies have their Registered office at Discovery House, Whiting Road, Norwich NR4 6EJ. 

All products are open only to residents of the United Kingdom.

This message has been checked for viruses and spam by the Virgin Money email scanning system powered by Messagelabs.

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Struts 2.0 form bean

Posted by Dave Newton <ne...@yahoo.com>.
--- Manoj.Gupta@virginmoney.com wrote:
> In the action class i defined a attribute called
> 
>     public PersonalDetailForm getForm() {
>         return form;
>     }
> 
>     public void setForm(PersonalDetailForm form) {
>         this.form = form;
>     }
> 
>     PersonalDetailForm form;
> 
> 
> and the jsp looks like
> <s:form action="doPersonal" method="POST"
> name="form">
>     <s:actionerror />
>     <s:fielderror />
>     <s:textfield name="name" label="Name" />  <br/>
>     <s:textfield name="dob" label="Date of birth" />

How would S2 know what "name" belonged to if you
didn't say "form.name" ?

Personally I think you're going about the problem the
wrong way; I'd think less in terms of S1.

d.



       
____________________________________________________________________________________
Moody friends. Drama queens. Your life? Nope! - their life, your story. Play Sims Stories at Yahoo! Games.
http://sims.yahoo.com/  

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Struts 2.0 form bean

Posted by Ma...@virginmoney.com.
Hi Dave,

Thanks for your reply.
I tried defining a java bean  as below

public class PersonalDetailForm implements Serializable {

    String name;
    String dob;
    String city;

    public PersonalDetailForm() {}

// also defined all the getter setter methods....
}


In the action class i defined a attribute called

    public PersonalDetailForm getForm() {
        return form;
    }

    public void setForm(PersonalDetailForm form) {
        this.form = form;
    }

    PersonalDetailForm form;


and the jsp looks like
<s:form action="doPersonal" method="POST" name="form">
    <s:actionerror />
    <s:fielderror />
    <s:textfield name="name" label="Name" />  <br/>
    <s:textfield name="dob" label="Date of birth" /> <br/>
    <s:textfield name="city" label="city" />  <br/>
    <s:submit value="Next" align="center"/>
</s:form>




in the action class when i do a form.getCity() it throws a
NUllPointerException....
i think the form is not initialised on the form submission... unlike struts
1.x we cannot confire the bean class in the struts-config.xml....

Can you please help?

Manoj.





                                                                           
             Dave Newton                                                   
             <newton.dave@yaho                                             
             o.com>                                                     To 
                                       Struts Users Mailing List           
             29/06/2007 13:53          <us...@struts.apache.org>            
                                                                        cc 
                                                                           
             Please respond to                                     Subject 
               "Struts Users           Re: Struts 2.0 form bean            
               Mailing List"                                               
             <user@struts.apac                                             
                  he.org>                                                  
                                                                           
                                                                           
                                                                           




--- Manoj.Gupta@virginmoney.com wrote:
> is there any way of defining this fields attribute
> in two separate bean classes and configure with the
> appropriate action?

Use regular JavaBeans and use the appropriate bean in
the JSP form and configure validation for each
bean/method combination.

That's a really, really long signature.








This e-mail is intended to be confidential to the recipient. If you receive a copy in error, please inform the sender and then delete this message. Virgin Money do not accept responsibility for changes made to any e-mail after sending. Virgin Money have swept, and believe this e-mail to be free of viruses and profanity but make no guarantees to this effect.

Virgin Money Personal Financial Service Ltd is authorised and regulated by the Financial Services Authority. Registered in England no. 3072766. Entered on the Financial Services Authority's Register http://www.fsa.gov.uk/register/. Register Number 179271. The Virgin Deposit Account is a personal bank account with The Royal Bank of Scotland.

Virgin Money Unit Trust Managers Ltd is authorised and regulated by the Financial Services Authority. Registered in England no. 3000482. Entered on the Financial Services Authority's Register. Register Number 171748.

Virgin Money Ltd. Registered in England no. 4232392. Introducer appointed representative only of Virgin Money Personal Financial Service Ltd.

Virgin Money Management Services Ltd. Registered in England no.3072772.

Virgin Money Group Ltd. Registered in England no.3087587.

All the above companies have their Registered office at Discovery House, Whiting Road, Norwich NR4 6EJ. 

All products are open only to residents of the United Kingdom.

This message has been checked for viruses and spam by the Virgin Money email scanning system powered by Messagelabs.

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Struts 2.0 form bean

Posted by Dave Newton <ne...@yahoo.com>.
--- Manoj.Gupta@virginmoney.com wrote:
> is there any way of defining this fields attribute
> in two separate bean classes and configure with the 
> appropriate action?

Use regular JavaBeans and use the appropriate bean in
the JSP form and configure validation for each
bean/method combination.

That's a really, really long signature.

> This e-mail is intended to be confidential to the
> recipient. If you receive a copy in error, please
> inform the sender and then delete this message.
> Virgin Money do not accept responsibility for
> changes made to any e-mail after sending. Virgin
> Money have swept, and believe this e-mail to be free
> of viruses and profanity but make no guarantees to
> this effect.
> 
> Virgin Money Personal Financial Service Ltd is
> authorised and regulated by the Financial Services
> Authority. Registered in England no. 3072766.
> Entered on the Financial Services Authority's
> Register http://www.fsa.gov.uk/register/. Register
> Number 179271. The Virgin Deposit Account is a
> personal bank account with The Royal Bank of
> Scotland.
> 
> Virgin Money Unit Trust Managers Ltd is authorised
> and regulated by the Financial Services Authority.
> Registered in England no. 3000482. Entered on the
> Financial Services Authority's Register. Register
> Number 171748.
> 
> Virgin Money Ltd. Registered in England no. 4232392.
> Introducer appointed representative only of Virgin
> Money Personal Financial Service Ltd.
> 
> Virgin Money Management Services Ltd. Registered in
> England no.3072772.
> 
> Virgin Money Group Ltd. Registered in England
> no.3087587.
> 
> All the above companies have their Registered office
> at Discovery House, Whiting Road, Norwich NR4 6EJ. 
> 
> All products are open only to residents of the
> United Kingdom.
> 
> This message has been checked for viruses and spam
> by the Virgin Money email scanning system powered by
> Messagelabs.

d.



       
____________________________________________________________________________________Ready for the edge of your seat? 
Check out tonight's top picks on Yahoo! TV. 
http://tv.yahoo.com/

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Struts 2.0 form bean

Posted by tom tom <j_...@yahoo.com>.
Before anything try model driven interface if you are
not doing any portlet developments.

Thanks,
--- Manoj.Gupta@virginmoney.com wrote:

> Hi All,
> 
> As there is no concept of Action form beans in
> struts 2.0 we have to define
> the field attributes in the Action class.
> 
> I am using the same action class for two form
> submission, is there any way
> of configuring form beans to this actions.
> 
> For example  if  my first form has fields name,
> address, sex and second
> form has  company, salary.
> I am using the same action class for the above form
> submission i.e.
> processPersonalDetails()  and
> processEmplymentDetails()
> is there any way of defining this fields attribute
> in two separate bean
> classes and configure with the appropriate action.?
> 
> Thanks,
> Manoj.
> 
> 
> This e-mail is intended to be confidential to the
> recipient. If you receive a copy in error, please
> inform the sender and then delete this message.
> Virgin Money do not accept responsibility for
> changes made to any e-mail after sending. Virgin
> Money have swept, and believe this e-mail to be free
> of viruses and profanity but make no guarantees to
> this effect.
> 
> Virgin Money Personal Financial Service Ltd is
> authorised and regulated by the Financial Services
> Authority. Registered in England no. 3072766.
> Entered on the Financial Services Authority's
> Register http://www.fsa.gov.uk/register/. Register
> Number 179271. The Virgin Deposit Account is a
> personal bank account with The Royal Bank of
> Scotland.
> 
> Virgin Money Unit Trust Managers Ltd is authorised
> and regulated by the Financial Services Authority.
> Registered in England no. 3000482. Entered on the
> Financial Services Authority's Register. Register
> Number 171748.
> 
> Virgin Money Ltd. Registered in England no. 4232392.
> Introducer appointed representative only of Virgin
> Money Personal Financial Service Ltd.
> 
> Virgin Money Management Services Ltd. Registered in
> England no.3072772.
> 
> Virgin Money Group Ltd. Registered in England
> no.3087587.
> 
> All the above companies have their Registered office
> at Discovery House, Whiting Road, Norwich NR4 6EJ. 
> 
> All products are open only to residents of the
> United Kingdom.
> 
> This message has been checked for viruses and spam
> by the Virgin Money email scanning system powered by
> Messagelabs.
> 
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> user-unsubscribe@struts.apache.org
> For additional commands, e-mail:
> user-help@struts.apache.org
> 
> 



       
____________________________________________________________________________________
Get the Yahoo! toolbar and be alerted to new email wherever you're surfing.
http://new.toolbar.yahoo.com/toolbar/features/mail/index.php

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org