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...@yahoo.com on 2007/04/06 18:32:09 UTC

populating a bean

how do I populate a bean values from a jsp page ?

here's what I need to do:


<s:form action="accountManager"  method="post" >
<s:textfield name="accountBean.firstName" label="First Name" />
<s:submit> </s:submit>
</s:form>


this page 
http://struts.apache.org/2.0.6/docs/how-do-i-populate-a-form-bean-and-get-the-value-using-the-taglib.html 

how to read the values from the bean but not how to populate them. Or 
may be I am not getting it...






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


Re: populating a bean

Posted by ma...@yahoo.com.
I found it. Never mind.
And thank you a lot for your help.


mansour77@yahoo.com wrote:
> Hartrich, James CTR USTRANSCOM J6 wrote:
>> So you are going from the jsp to the action, correct?
>> That being the case, you are doing this correctly so far. Make certain
>> to have an encapsulated property for accountBean in your accountManager
>> action. On submit the accountBean object will be constructed and
>> setFirstName will be called. The bean will be set on your accountManager
>> action.   
> that's exactly what I am doing. But it's not populating the field. The 
> field still shows null.
> Here's a code from my AccountManager:
>
>
> public class AccountManager   extends ActionSupport{
>
>    private Account account ;
>    private AccountBean accountBean ;
>      public String execute()
>    {
>        // TODO - read the coments
>        //if there's account number then retrieve the correspondiing 
> account and dislay
>        //if there's field for the accout then create the account and 
> dislay
>        //if none then forward to the new account page
>        return "SUCCESS" ;  //temporarily
>    }
>
>    public AccountBean getAccountBean() {
>        return accountBean;
>    }
>
>    public void setAccountBean(AccountBean accountBean) {
>        this.accountBean = accountBean;
>    }
>   }
>
>
>> -----Original Message-----
>> From: mansour77@yahoo.com [mailto:mansour77@yahoo.com] Sent: Friday, 
>> April 06, 2007 11:32 AM
>> To: Struts Users Mailing List
>> Subject: populating a bean
>>
>> how do I populate a bean values from a jsp page ?
>>
>> here's what I need to do:
>>
>>
>> <s:form action="accountManager"  method="post" >
>> <s:textfield name="accountBean.firstName" label="First Name" />
>> <s:submit> </s:submit>
>> </s:form>
>>
>>
>> this page 
>> http://struts.apache.org/2.0.6/docs/how-do-i-populate-a-form-bean-and-ge
>> t-the-value-using-the-taglib.html
>> how to read the values from the bean but not how to populate them. Or 
>> may be I am not getting it...
>>
>>
>>
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>>
>>
>>   
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>


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


Re: populating a bean

Posted by Martin Gainty <mg...@hotmail.com>.
Assuming you are using Struts-2?
http://struts.apache.org/2.x/struts2-core/apidocs/org/apache/struts2/dispatcher/DefaultActionSupport.html#getSuccessResultValue()
you will need these methods
public String getSuccessResultValue()
public void setSuccessResultValue(String successResultValue)

Martin--
This email message and any files transmitted with it contain confidential
information intended only for the person(s) to whom this email message is
addressed.  If you have received this email message in error, please notify
the sender immediately by telephone or email and destroy the original
message without making a copy.  Thank you.

----- Original Message ----- 
From: <ma...@yahoo.com>
To: "Struts Users Mailing List" <us...@struts.apache.org>
Sent: Friday, April 06, 2007 12:47 PM
Subject: Re: populating a bean


> Hartrich, James CTR USTRANSCOM J6 wrote:
>> So you are going from the jsp to the action, correct?
>> That being the case, you are doing this correctly so far. Make certain
>> to have an encapsulated property for accountBean in your accountManager
>> action. On submit the accountBean object will be constructed and
>> setFirstName will be called. The bean will be set on your accountManager
>> action.
> that's exactly what I am doing. But it's not populating the field. The 
> field still shows null.
> Here's a code from my AccountManager:
>
>
> public class AccountManager   extends ActionSupport{
>
>    private Account account ;
>    private AccountBean accountBean ;
>   public String execute()
>    {
>        // TODO - read the coments
>        //if there's account number then retrieve the correspondiing 
> account and dislay
>        //if there's field for the accout then create the account and 
> dislay
>        //if none then forward to the new account page
>        return "SUCCESS" ;  //temporarily
>    }
>
>    public AccountBean getAccountBean() {
>        return accountBean;
>    }
>
>    public void setAccountBean(AccountBean accountBean) {
>        this.accountBean = accountBean;
>    }
>   }
>
>
>> -----Original Message-----
>> From: mansour77@yahoo.com [mailto:mansour77@yahoo.com] Sent: Friday, 
>> April 06, 2007 11:32 AM
>> To: Struts Users Mailing List
>> Subject: populating a bean
>>
>> how do I populate a bean values from a jsp page ?
>>
>> here's what I need to do:
>>
>>
>> <s:form action="accountManager"  method="post" >
>> <s:textfield name="accountBean.firstName" label="First Name" />
>> <s:submit> </s:submit>
>> </s:form>
>>
>>
>> this page 
>> http://struts.apache.org/2.0.6/docs/how-do-i-populate-a-form-bean-and-ge
>> t-the-value-using-the-taglib.html
>> how to read the values from the bean but not how to populate them. Or may 
>> be I am not getting it...
>>
>>
>>
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>>
>>
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
> 


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


Re: populating a bean

Posted by ma...@yahoo.com.
Hartrich, James CTR USTRANSCOM J6 wrote:
> So you are going from the jsp to the action, correct?
> That being the case, you are doing this correctly so far. Make certain
> to have an encapsulated property for accountBean in your accountManager
> action. On submit the accountBean object will be constructed and
> setFirstName will be called. The bean will be set on your accountManager
> action. 
>   
that's exactly what I am doing. But it's not populating the field. The 
field still shows null.
Here's a code from my AccountManager:


public class AccountManager   extends ActionSupport{

    private Account account ;
    private AccountBean accountBean ;
   
    public String execute()
    {
        // TODO - read the coments
        //if there's account number then retrieve the correspondiing 
account and dislay
        //if there's field for the accout then create the account and dislay
        //if none then forward to the new account page
        return "SUCCESS" ;  //temporarily
    }

    public AccountBean getAccountBean() {
        return accountBean;
    }

    public void setAccountBean(AccountBean accountBean) {
        this.accountBean = accountBean;
    }
   
}


> -----Original Message-----
> From: mansour77@yahoo.com [mailto:mansour77@yahoo.com] 
> Sent: Friday, April 06, 2007 11:32 AM
> To: Struts Users Mailing List
> Subject: populating a bean
>
> how do I populate a bean values from a jsp page ?
>
> here's what I need to do:
>
>
> <s:form action="accountManager"  method="post" >
> <s:textfield name="accountBean.firstName" label="First Name" />
> <s:submit> </s:submit>
> </s:form>
>
>
> this page 
> http://struts.apache.org/2.0.6/docs/how-do-i-populate-a-form-bean-and-ge
> t-the-value-using-the-taglib.html 
>
> how to read the values from the bean but not how to populate them. Or 
> may be I am not getting it...
>
>
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
>   


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


RE: populating a bean

Posted by "Hartrich, James CTR USTRANSCOM J6" <Ja...@ustranscom.mil>.
So you are going from the jsp to the action, correct?
That being the case, you are doing this correctly so far. Make certain
to have an encapsulated property for accountBean in your accountManager
action. On submit the accountBean object will be constructed and
setFirstName will be called. The bean will be set on your accountManager
action. 

-----Original Message-----
From: mansour77@yahoo.com [mailto:mansour77@yahoo.com] 
Sent: Friday, April 06, 2007 11:32 AM
To: Struts Users Mailing List
Subject: populating a bean

how do I populate a bean values from a jsp page ?

here's what I need to do:


<s:form action="accountManager"  method="post" >
<s:textfield name="accountBean.firstName" label="First Name" />
<s:submit> </s:submit>
</s:form>


this page 
http://struts.apache.org/2.0.6/docs/how-do-i-populate-a-form-bean-and-ge
t-the-value-using-the-taglib.html 

how to read the values from the bean but not how to populate them. Or 
may be I am not getting it...






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


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