You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by maven apache <ap...@gmail.com> on 2010/11/29 11:58:58 UTC

binding paramters in struts2 without the form

<s:form action="register">

      <s:textfield name="personBean.firstName" label="First name" />

      <s:submit/>
</s:form>

public class Register extends ActionSupport {

    private static final long serialVersionUID = 1L;

    private Person personBean;

        //................
}


Using the s:form tag one can bind the parameter from the client to a java
object(the personBean in the Register action).

However it seems that the struts tag is required,but my action is not called
from the web form,so any way?

And I tried this way:

public class ParaWrapper(){

  private String firstName;

  public void setFirstName(String ..){

    this.firstName=...

  }
  //the getter of firstName

  public ....
}


public MyAction extends ActionSupport{

  private ParaWrapper wrapper;

  public void setXXX()...

  public void getXXX()...

  public void execute(){

    System.out.println(wrapper.getFirstName()); //here I can not get
the parameters,it seems that the parameters are not populated to this
object.

  }
}

It does not work since struts does not know which object should be
used to bind the parameter.


I wonder there is any way to using this manner?

Re: binding paramters in struts2 without the form

Posted by Li Ying <li...@gmail.com>.
> Struts will not automatically populate fields based on parameters passed via
> the URL

I always use URL to binding parameters to Action.

And I have read source code of ParametersInterceptor, I think this
Interceptor will populate all the params to Action.

And it dose not treat params via URL or via POST differently.

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


Re: binding paramters in struts2 without the form

Posted by maven apache <ap...@gmail.com>.
Thank you very much.

I found the ModelDriven is very useful. With it I donot have to add the
parametes to the action as the fields.

:)

2010/11/29 Maurizio Cucchiara <ma...@gmail.com>

> If you don't want dot notation, I should consider using ModelDriven
> interface. Take a look at
>
> http://struts.apache.org/2.2.1/struts2-core/apidocs/com/opensymphony/xwork2/ModelDriven.html
>
> 2010/11/29 maven apache <ap...@gmail.com>:
>
> > Maurizio Cucchiara's answer seems like a good idea excepting I have add
> the
> > personbean.name=xxx. (The personBean is required)
> >
> > I do not want to use the ParameterAware,I want to use a object save some
> > default value of some parameters rather than  the map.
> >
> > Also,if using the parameterAware,why not using the
> > ActionContext.getcontext().getParameters() instead?
> >
> >
> >
> >>
> >> Jason
> >>
> >> On Mon, Nov 29, 2010 at 5:25 AM, maven apache <apachemaven0@gmail.com
> >> >wrote:
> >>
> >> > 2010/11/29 Maurizio Cucchiara <ma...@gmail.com>
> >> >
> >> > > Frankly, even after I watched your question on stackoverflow, I
> can't
> >> > > figure out what you meant.
> >> > >
> >> > :(
> >> >
> >> > > You don't necessary need struts tag, you can pass parameter via http
> >> > > request, so, for example, if you enter
> >> > > http://your_url:your_port
> >> > > /your_struts.action?personBean.firstName=your_name
> >> > >  in the address bar
> >> > >
> >> > Thanks.
> >> >
> >> > I use the http://xxx.action?firstName=name. So it does not work.
> >> >
> >> >
> >> > http://your_url:your_port
> >> > /your_struts.action?personBean.firstName=your_name
> >> >
> >> > I do not know the parameter can be sent this way!!!
> >> > Thanks.
> >> >
> >> >
> >> > > struts will try to inject value inside your bean.
> >> > >
> >> > > Does this answer your question?
> >> > >
> >> > > 2010/11/29 maven apache <ap...@gmail.com>:
> >> > > > BTW,this is a cross post at
> >> > > > stackoverflow<
> >> > >
> >> >
> >>
> http://stackoverflow.com/questions/4300409/binding-paramters-in-struts2-without-the-form
> >> > > >
> >> > > > .
> >> > > >
> >> > > > 2010/11/29 maven apache <ap...@gmail.com>
> >> > > >
> >> > > >> <s:form action="register">
> >> > > >>
> >> > > >>
> >> > > >>       <s:textfield name="personBean.firstName" label="First name"
> />
> >> > > >>
> >> > > >>
> >> > > >>       <s:submit/>
> >> > > >> </s:form>
> >> > > >>
> >> > > >> public class Register extends ActionSupport {
> >> > > >>
> >> > > >>
> >> > > >>     private static final long serialVersionUID = 1L;
> >> > > >>
> >> > > >>
> >> > > >>     private Person personBean;
> >> > > >>
> >> > > >>
> >> > > >>         //................
> >> > > >> }
> >> > > >>
> >> > > >>
> >> > > >> Using the s:form tag one can bind the parameter from the client
> to a
> >> > > java
> >> > > >> object(the personBean in the Register action).
> >> > > >>
> >> > > >> However it seems that the struts tag is required,but my action is
> >> not
> >> > > >> called from the web form,so any way?
> >> > > >>
> >> > > >> And I tried this way:
> >> > > >>
> >> > > >> public class ParaWrapper(){
> >> > > >>
> >> > > >>
> >> > > >>   private String firstName;
> >> > > >>
> >> > > >>
> >> > > >>   public void setFirstName(String ..){
> >> > > >>
> >> > > >>
> >> > > >>     this.firstName=...
> >> > > >>
> >> > > >>
> >> > > >>   }
> >> > > >>   //the getter of firstName
> >> > > >>
> >> > > >>
> >> > > >>   public ....
> >> > > >>
> >> > > >> }
> >> > > >>
> >> > > >>
> >> > > >> public MyAction extends ActionSupport{
> >> > > >>
> >> > > >>
> >> > > >>   private ParaWrapper wrapper;
> >> > > >>
> >> > > >>
> >> > > >>   public void setXXX()...
> >> > > >>
> >> > > >>
> >> > > >>   public void getXXX()...
> >> > > >>
> >> > > >>
> >> > > >>   public void execute(){
> >> > > >>
> >> > > >>
> >> > > >>     System.out.println(wrapper.getFirstName()); //here I can not
> get
> >> > the
> >> > > parameters,it seems that the parameters are not populated to this
> >> object.
> >> > > >>
> >> > > >>
> >> > > >>   }
> >> > > >> }
> >> > > >>
> >> > > >> It does not work since struts does not know which object should
> be
> >> > used
> >> > > to bind the parameter.
> >> > > >>
> >> > > >>
> >> > > >> I wonder there is any way to using this manner?
> >> > > >>
> >> > > >>
> >> > > >
> >> > >
> >> > >
> >> > >
> >> > > --
> >> > > Maurizio Cucchiara
> >> > >
> >> > >
> ---------------------------------------------------------------------
> >> > > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> >> > > For additional commands, e-mail: user-help@struts.apache.org
> >> > >
> >> > >
> >> >
> >>
> >
>
>
>
> --
> Maurizio Cucchiara
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>

Re: binding paramters in struts2 without the form

Posted by Maurizio Cucchiara <ma...@gmail.com>.
If you don't want dot notation, I should consider using ModelDriven
interface. Take a look at
http://struts.apache.org/2.2.1/struts2-core/apidocs/com/opensymphony/xwork2/ModelDriven.html

2010/11/29 maven apache <ap...@gmail.com>:

> Maurizio Cucchiara's answer seems like a good idea excepting I have add the
> personbean.name=xxx. (The personBean is required)
>
> I do not want to use the ParameterAware,I want to use a object save some
> default value of some parameters rather than  the map.
>
> Also,if using the parameterAware,why not using the
> ActionContext.getcontext().getParameters() instead?
>
>
>
>>
>> Jason
>>
>> On Mon, Nov 29, 2010 at 5:25 AM, maven apache <apachemaven0@gmail.com
>> >wrote:
>>
>> > 2010/11/29 Maurizio Cucchiara <ma...@gmail.com>
>> >
>> > > Frankly, even after I watched your question on stackoverflow, I can't
>> > > figure out what you meant.
>> > >
>> > :(
>> >
>> > > You don't necessary need struts tag, you can pass parameter via http
>> > > request, so, for example, if you enter
>> > > http://your_url:your_port
>> > > /your_struts.action?personBean.firstName=your_name
>> > >  in the address bar
>> > >
>> > Thanks.
>> >
>> > I use the http://xxx.action?firstName=name. So it does not work.
>> >
>> >
>> > http://your_url:your_port
>> > /your_struts.action?personBean.firstName=your_name
>> >
>> > I do not know the parameter can be sent this way!!!
>> > Thanks.
>> >
>> >
>> > > struts will try to inject value inside your bean.
>> > >
>> > > Does this answer your question?
>> > >
>> > > 2010/11/29 maven apache <ap...@gmail.com>:
>> > > > BTW,this is a cross post at
>> > > > stackoverflow<
>> > >
>> >
>> http://stackoverflow.com/questions/4300409/binding-paramters-in-struts2-without-the-form
>> > > >
>> > > > .
>> > > >
>> > > > 2010/11/29 maven apache <ap...@gmail.com>
>> > > >
>> > > >> <s:form action="register">
>> > > >>
>> > > >>
>> > > >>       <s:textfield name="personBean.firstName" label="First name" />
>> > > >>
>> > > >>
>> > > >>       <s:submit/>
>> > > >> </s:form>
>> > > >>
>> > > >> public class Register extends ActionSupport {
>> > > >>
>> > > >>
>> > > >>     private static final long serialVersionUID = 1L;
>> > > >>
>> > > >>
>> > > >>     private Person personBean;
>> > > >>
>> > > >>
>> > > >>         //................
>> > > >> }
>> > > >>
>> > > >>
>> > > >> Using the s:form tag one can bind the parameter from the client to a
>> > > java
>> > > >> object(the personBean in the Register action).
>> > > >>
>> > > >> However it seems that the struts tag is required,but my action is
>> not
>> > > >> called from the web form,so any way?
>> > > >>
>> > > >> And I tried this way:
>> > > >>
>> > > >> public class ParaWrapper(){
>> > > >>
>> > > >>
>> > > >>   private String firstName;
>> > > >>
>> > > >>
>> > > >>   public void setFirstName(String ..){
>> > > >>
>> > > >>
>> > > >>     this.firstName=...
>> > > >>
>> > > >>
>> > > >>   }
>> > > >>   //the getter of firstName
>> > > >>
>> > > >>
>> > > >>   public ....
>> > > >>
>> > > >> }
>> > > >>
>> > > >>
>> > > >> public MyAction extends ActionSupport{
>> > > >>
>> > > >>
>> > > >>   private ParaWrapper wrapper;
>> > > >>
>> > > >>
>> > > >>   public void setXXX()...
>> > > >>
>> > > >>
>> > > >>   public void getXXX()...
>> > > >>
>> > > >>
>> > > >>   public void execute(){
>> > > >>
>> > > >>
>> > > >>     System.out.println(wrapper.getFirstName()); //here I can not get
>> > the
>> > > parameters,it seems that the parameters are not populated to this
>> object.
>> > > >>
>> > > >>
>> > > >>   }
>> > > >> }
>> > > >>
>> > > >> It does not work since struts does not know which object should be
>> > used
>> > > to bind the parameter.
>> > > >>
>> > > >>
>> > > >> I wonder there is any way to using this manner?
>> > > >>
>> > > >>
>> > > >
>> > >
>> > >
>> > >
>> > > --
>> > > Maurizio Cucchiara
>> > >
>> > > ---------------------------------------------------------------------
>> > > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> > > For additional commands, e-mail: user-help@struts.apache.org
>> > >
>> > >
>> >
>>
>



-- 
Maurizio Cucchiara

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


Re: binding paramters in struts2 without the form

Posted by maven apache <ap...@gmail.com>.
2010/11/29 Jason Ferguson <fe...@gmail.com>

> Struts will not automatically populate fields based on parameters passed
> via
> the URL. Your action will need to implement the ParameterAware interface,
> and the setParameters(Map<String, String[]> parameters) method. Then you
> can
> use the map to populate your fields.
>

Maurizio Cucchiara's answer seems like a good idea excepting I have add the
personbean.name=xxx. (The personBean is required)

I do not want to use the ParameterAware,I want to use a object save some
default value of some parameters rather than  the map.

Also,if using the parameterAware,why not using the
ActionContext.getcontext().getParameters() instead?



>
> Jason
>
> On Mon, Nov 29, 2010 at 5:25 AM, maven apache <apachemaven0@gmail.com
> >wrote:
>
> > 2010/11/29 Maurizio Cucchiara <ma...@gmail.com>
> >
> > > Frankly, even after I watched your question on stackoverflow, I can't
> > > figure out what you meant.
> > >
> > :(
> >
> > > You don't necessary need struts tag, you can pass parameter via http
> > > request, so, for example, if you enter
> > > http://your_url:your_port
> > > /your_struts.action?personBean.firstName=your_name
> > >  in the address bar
> > >
> > Thanks.
> >
> > I use the http://xxx.action?firstName=name. So it does not work.
> >
> >
> > http://your_url:your_port
> > /your_struts.action?personBean.firstName=your_name
> >
> > I do not know the parameter can be sent this way!!!
> > Thanks.
> >
> >
> > > struts will try to inject value inside your bean.
> > >
> > > Does this answer your question?
> > >
> > > 2010/11/29 maven apache <ap...@gmail.com>:
> > > > BTW,this is a cross post at
> > > > stackoverflow<
> > >
> >
> http://stackoverflow.com/questions/4300409/binding-paramters-in-struts2-without-the-form
> > > >
> > > > .
> > > >
> > > > 2010/11/29 maven apache <ap...@gmail.com>
> > > >
> > > >> <s:form action="register">
> > > >>
> > > >>
> > > >>       <s:textfield name="personBean.firstName" label="First name" />
> > > >>
> > > >>
> > > >>       <s:submit/>
> > > >> </s:form>
> > > >>
> > > >> public class Register extends ActionSupport {
> > > >>
> > > >>
> > > >>     private static final long serialVersionUID = 1L;
> > > >>
> > > >>
> > > >>     private Person personBean;
> > > >>
> > > >>
> > > >>         //................
> > > >> }
> > > >>
> > > >>
> > > >> Using the s:form tag one can bind the parameter from the client to a
> > > java
> > > >> object(the personBean in the Register action).
> > > >>
> > > >> However it seems that the struts tag is required,but my action is
> not
> > > >> called from the web form,so any way?
> > > >>
> > > >> And I tried this way:
> > > >>
> > > >> public class ParaWrapper(){
> > > >>
> > > >>
> > > >>   private String firstName;
> > > >>
> > > >>
> > > >>   public void setFirstName(String ..){
> > > >>
> > > >>
> > > >>     this.firstName=...
> > > >>
> > > >>
> > > >>   }
> > > >>   //the getter of firstName
> > > >>
> > > >>
> > > >>   public ....
> > > >>
> > > >> }
> > > >>
> > > >>
> > > >> public MyAction extends ActionSupport{
> > > >>
> > > >>
> > > >>   private ParaWrapper wrapper;
> > > >>
> > > >>
> > > >>   public void setXXX()...
> > > >>
> > > >>
> > > >>   public void getXXX()...
> > > >>
> > > >>
> > > >>   public void execute(){
> > > >>
> > > >>
> > > >>     System.out.println(wrapper.getFirstName()); //here I can not get
> > the
> > > parameters,it seems that the parameters are not populated to this
> object.
> > > >>
> > > >>
> > > >>   }
> > > >> }
> > > >>
> > > >> It does not work since struts does not know which object should be
> > used
> > > to bind the parameter.
> > > >>
> > > >>
> > > >> I wonder there is any way to using this manner?
> > > >>
> > > >>
> > > >
> > >
> > >
> > >
> > > --
> > > Maurizio Cucchiara
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > > For additional commands, e-mail: user-help@struts.apache.org
> > >
> > >
> >
>

Re: binding paramters in struts2 without the form

Posted by Dave Newton <da...@gmail.com>.
On Mon, Nov 29, 2010 at 6:55 AM, Jason Ferguson wrote:

> Struts will not automatically populate fields based on parameters passed
> via
> the URL. Your action will need to implement the ParameterAware interface,
> and the setParameters(Map<String, String[]> parameters) method. Then you
> can
> use the map to populate your fields.
>

It won't? Is this new behavior? It's always worked for me just fine.

Dave

Re: binding paramters in struts2 without the form

Posted by Jason Ferguson <fe...@gmail.com>.
Struts will not automatically populate fields based on parameters passed via
the URL. Your action will need to implement the ParameterAware interface,
and the setParameters(Map<String, String[]> parameters) method. Then you can
use the map to populate your fields.

Jason

On Mon, Nov 29, 2010 at 5:25 AM, maven apache <ap...@gmail.com>wrote:

> 2010/11/29 Maurizio Cucchiara <ma...@gmail.com>
>
> > Frankly, even after I watched your question on stackoverflow, I can't
> > figure out what you meant.
> >
> :(
>
> > You don't necessary need struts tag, you can pass parameter via http
> > request, so, for example, if you enter
> > http://your_url:your_port
> > /your_struts.action?personBean.firstName=your_name
> >  in the address bar
> >
> Thanks.
>
> I use the http://xxx.action?firstName=name. So it does not work.
>
>
> http://your_url:your_port
> /your_struts.action?personBean.firstName=your_name
>
> I do not know the parameter can be sent this way!!!
> Thanks.
>
>
> > struts will try to inject value inside your bean.
> >
> > Does this answer your question?
> >
> > 2010/11/29 maven apache <ap...@gmail.com>:
> > > BTW,this is a cross post at
> > > stackoverflow<
> >
> http://stackoverflow.com/questions/4300409/binding-paramters-in-struts2-without-the-form
> > >
> > > .
> > >
> > > 2010/11/29 maven apache <ap...@gmail.com>
> > >
> > >> <s:form action="register">
> > >>
> > >>
> > >>       <s:textfield name="personBean.firstName" label="First name" />
> > >>
> > >>
> > >>       <s:submit/>
> > >> </s:form>
> > >>
> > >> public class Register extends ActionSupport {
> > >>
> > >>
> > >>     private static final long serialVersionUID = 1L;
> > >>
> > >>
> > >>     private Person personBean;
> > >>
> > >>
> > >>         //................
> > >> }
> > >>
> > >>
> > >> Using the s:form tag one can bind the parameter from the client to a
> > java
> > >> object(the personBean in the Register action).
> > >>
> > >> However it seems that the struts tag is required,but my action is not
> > >> called from the web form,so any way?
> > >>
> > >> And I tried this way:
> > >>
> > >> public class ParaWrapper(){
> > >>
> > >>
> > >>   private String firstName;
> > >>
> > >>
> > >>   public void setFirstName(String ..){
> > >>
> > >>
> > >>     this.firstName=...
> > >>
> > >>
> > >>   }
> > >>   //the getter of firstName
> > >>
> > >>
> > >>   public ....
> > >>
> > >> }
> > >>
> > >>
> > >> public MyAction extends ActionSupport{
> > >>
> > >>
> > >>   private ParaWrapper wrapper;
> > >>
> > >>
> > >>   public void setXXX()...
> > >>
> > >>
> > >>   public void getXXX()...
> > >>
> > >>
> > >>   public void execute(){
> > >>
> > >>
> > >>     System.out.println(wrapper.getFirstName()); //here I can not get
> the
> > parameters,it seems that the parameters are not populated to this object.
> > >>
> > >>
> > >>   }
> > >> }
> > >>
> > >> It does not work since struts does not know which object should be
> used
> > to bind the parameter.
> > >>
> > >>
> > >> I wonder there is any way to using this manner?
> > >>
> > >>
> > >
> >
> >
> >
> > --
> > Maurizio Cucchiara
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > For additional commands, e-mail: user-help@struts.apache.org
> >
> >
>

Re: binding paramters in struts2 without the form

Posted by maven apache <ap...@gmail.com>.
2010/11/29 Maurizio Cucchiara <ma...@gmail.com>

> Frankly, even after I watched your question on stackoverflow, I can't
> figure out what you meant.
>
:(

> You don't necessary need struts tag, you can pass parameter via http
> request, so, for example, if you enter
> http://your_url:your_port
> /your_struts.action?personBean.firstName=your_name
>  in the address bar
>
Thanks.

I use the http://xxx.action?firstName=name. So it does not work.


http://your_url:your_port/your_struts.action?personBean.firstName=your_name

I do not know the parameter can be sent this way!!!
Thanks.


> struts will try to inject value inside your bean.
>
> Does this answer your question?
>
> 2010/11/29 maven apache <ap...@gmail.com>:
> > BTW,this is a cross post at
> > stackoverflow<
> http://stackoverflow.com/questions/4300409/binding-paramters-in-struts2-without-the-form
> >
> > .
> >
> > 2010/11/29 maven apache <ap...@gmail.com>
> >
> >> <s:form action="register">
> >>
> >>
> >>       <s:textfield name="personBean.firstName" label="First name" />
> >>
> >>
> >>       <s:submit/>
> >> </s:form>
> >>
> >> public class Register extends ActionSupport {
> >>
> >>
> >>     private static final long serialVersionUID = 1L;
> >>
> >>
> >>     private Person personBean;
> >>
> >>
> >>         //................
> >> }
> >>
> >>
> >> Using the s:form tag one can bind the parameter from the client to a
> java
> >> object(the personBean in the Register action).
> >>
> >> However it seems that the struts tag is required,but my action is not
> >> called from the web form,so any way?
> >>
> >> And I tried this way:
> >>
> >> public class ParaWrapper(){
> >>
> >>
> >>   private String firstName;
> >>
> >>
> >>   public void setFirstName(String ..){
> >>
> >>
> >>     this.firstName=...
> >>
> >>
> >>   }
> >>   //the getter of firstName
> >>
> >>
> >>   public ....
> >>
> >> }
> >>
> >>
> >> public MyAction extends ActionSupport{
> >>
> >>
> >>   private ParaWrapper wrapper;
> >>
> >>
> >>   public void setXXX()...
> >>
> >>
> >>   public void getXXX()...
> >>
> >>
> >>   public void execute(){
> >>
> >>
> >>     System.out.println(wrapper.getFirstName()); //here I can not get the
> parameters,it seems that the parameters are not populated to this object.
> >>
> >>
> >>   }
> >> }
> >>
> >> It does not work since struts does not know which object should be used
> to bind the parameter.
> >>
> >>
> >> I wonder there is any way to using this manner?
> >>
> >>
> >
>
>
>
> --
> Maurizio Cucchiara
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>

Re: binding paramters in struts2 without the form

Posted by Maurizio Cucchiara <ma...@gmail.com>.
Frankly, even after I watched your question on stackoverflow, I can't
figure out what you meant.
You don't necessary need struts tag, you can pass parameter via http
request, so, for example, if you enter
http://your_url:your_port/your_struts.action?personBean.firstName=your_name
 in the address bar
struts will try to inject value inside your bean.

Does this answer your question?

2010/11/29 maven apache <ap...@gmail.com>:
> BTW,this is a cross post at
> stackoverflow<http://stackoverflow.com/questions/4300409/binding-paramters-in-struts2-without-the-form>
> .
>
> 2010/11/29 maven apache <ap...@gmail.com>
>
>> <s:form action="register">
>>
>>
>>       <s:textfield name="personBean.firstName" label="First name" />
>>
>>
>>       <s:submit/>
>> </s:form>
>>
>> public class Register extends ActionSupport {
>>
>>
>>     private static final long serialVersionUID = 1L;
>>
>>
>>     private Person personBean;
>>
>>
>>         //................
>> }
>>
>>
>> Using the s:form tag one can bind the parameter from the client to a java
>> object(the personBean in the Register action).
>>
>> However it seems that the struts tag is required,but my action is not
>> called from the web form,so any way?
>>
>> And I tried this way:
>>
>> public class ParaWrapper(){
>>
>>
>>   private String firstName;
>>
>>
>>   public void setFirstName(String ..){
>>
>>
>>     this.firstName=...
>>
>>
>>   }
>>   //the getter of firstName
>>
>>
>>   public ....
>>
>> }
>>
>>
>> public MyAction extends ActionSupport{
>>
>>
>>   private ParaWrapper wrapper;
>>
>>
>>   public void setXXX()...
>>
>>
>>   public void getXXX()...
>>
>>
>>   public void execute(){
>>
>>
>>     System.out.println(wrapper.getFirstName()); //here I can not get the parameters,it seems that the parameters are not populated to this object.
>>
>>
>>   }
>> }
>>
>> It does not work since struts does not know which object should be used to bind the parameter.
>>
>>
>> I wonder there is any way to using this manner?
>>
>>
>



-- 
Maurizio Cucchiara

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


Re: binding paramters in struts2 without the form

Posted by maven apache <ap...@gmail.com>.
BTW,this is a cross post at
stackoverflow<http://stackoverflow.com/questions/4300409/binding-paramters-in-struts2-without-the-form>
.

2010/11/29 maven apache <ap...@gmail.com>

> <s:form action="register">
>
>
>       <s:textfield name="personBean.firstName" label="First name" />
>
>
>       <s:submit/>
> </s:form>
>
> public class Register extends ActionSupport {
>
>
>     private static final long serialVersionUID = 1L;
>
>
>     private Person personBean;
>
>
>         //................
> }
>
>
> Using the s:form tag one can bind the parameter from the client to a java
> object(the personBean in the Register action).
>
> However it seems that the struts tag is required,but my action is not
> called from the web form,so any way?
>
> And I tried this way:
>
> public class ParaWrapper(){
>
>
>   private String firstName;
>
>
>   public void setFirstName(String ..){
>
>
>     this.firstName=...
>
>
>   }
>   //the getter of firstName
>
>
>   public ....
>
> }
>
>
> public MyAction extends ActionSupport{
>
>
>   private ParaWrapper wrapper;
>
>
>   public void setXXX()...
>
>
>   public void getXXX()...
>
>
>   public void execute(){
>
>
>     System.out.println(wrapper.getFirstName()); //here I can not get the parameters,it seems that the parameters are not populated to this object.
>
>
>   }
> }
>
> It does not work since struts does not know which object should be used to bind the parameter.
>
>
> I wonder there is any way to using this manner?
>
>