You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Mailing Lists <li...@the-adams-family.net> on 2007/02/16 18:33:30 UTC

[s2] formbean reset() equivalent?

How do you initialize values to use in a form?

I tried just initializing the value in the action and referencing it in the
form, but the value is not set.

In action:

private String test = "tesing";

in form:

<s:textfield value="%{test}"/>

Re: [s2] formbean reset() equivalent?

Posted by Dave Newton <ne...@yahoo.com>.
--- "C. Adams" <li...@the-adams-family.net> wrote:
> I was just going directly to the jsp with the form,
> like I used to in struts 1.x. It looks like the 
> preferred way to do it now is to wildcard the action
> name, add a input result, and then access the form
> via myActionName_input.action
> 
> This is working fine. Is this the preferred method?

If you want it to pay any sort of attention to things
that are in your Action class, yes, otherwise how
would it know what you wanted to use for values?

Dave



 
____________________________________________________________________________________
Finding fabulous fares is fun.  
Let Yahoo! FareChase search your favorite travel sites to find flight and hotel bargains.
http://farechase.yahoo.com/promo-generic-14795097

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


Re: [s2] formbean reset() equivalent?

Posted by "C. Adams" <li...@the-adams-family.net>.
I was just going directly to the jsp with the form, like I used to in struts
1.x. It looks like the preferred way to do it now is to wildcard the action
name, add a input result, and then access the form via
myActionName_input.action

This is working fine. Is this the preferred method?


On 2/20/07, Dave Newton <ne...@yahoo.com> wrote:
>
> --- "C. Adams" <li...@the-adams-family.net> wrote:
> > Maybe it should, but it doesn't. The value of test
> > is always blank, and a println I put in the getter
> > does not show up in the log. I don't thing the
> > action is being instantiated until after the form is
> > submitted.
>
> Actions are instantiated per-request. If you are using
> the Action as the input Action for the form and
> setting a value to something exposed to the JSP then
> it will show up.
>
> If you can reduce (and duplicate) your problem then
> post the relevent config, Action, and JSP chunks.
>
> Are you using the standard result name of "input" for
> the input page?
>
> Dave
>
>
>
>
>
> ____________________________________________________________________________________
> Food fight? Enjoy some healthy debate
> in the Yahoo! Answers Food & Drink Q&A.
> http://answers.yahoo.com/dir/?link=list&sid=396545367
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>

Re: [s2] formbean reset() equivalent?

Posted by Dave Newton <ne...@yahoo.com>.
--- "C. Adams" <li...@the-adams-family.net> wrote:
> Maybe it should, but it doesn't. The value of test
> is always blank, and a println I put in the getter 
> does not show up in the log. I don't thing the
> action is being instantiated until after the form is
> submitted.

Actions are instantiated per-request. If you are using
the Action as the input Action for the form and
setting a value to something exposed to the JSP then
it will show up.

If you can reduce (and duplicate) your problem then
post the relevent config, Action, and JSP chunks.

Are you using the standard result name of "input" for
the input page?

Dave



 
____________________________________________________________________________________
Food fight? Enjoy some healthy debate 
in the Yahoo! Answers Food & Drink Q&A.
http://answers.yahoo.com/dir/?link=list&sid=396545367

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


Re: [s2] formbean reset() equivalent?

Posted by "C. Adams" <li...@the-adams-family.net>.
Maybe it should, but it doesn't. The value of test is always blank, and a
println I put in the getter does not show up in the log. I don't thing the
action is being instantiated until after the form is submitted.


On 2/17/07, Laurie Harper <la...@holoweb.net> wrote:
>
> Mailing Lists wrote:
> > How do you initialize values to use in a form?
> >
> > I tried just initializing the value in the action and referencing it in
> the
> > form, but the value is not set.
> >
> > In action:
> >
> > private String test = "tesing";
> >
> > in form:
> >
> > <s:textfield value="%{test}"/>
>
> That should work fine, provided you have a getter for the 'test'
> property in your action.
>
> In general, there is no equivalent of the Struts1 form bean reset()
> method in Struts2, since there's no need: the action and the form bean
> are the same thing, and get instantiated once per request.
>
> L.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>

Re: [s2] formbean reset() equivalent?

Posted by Laurie Harper <la...@holoweb.net>.
Mailing Lists wrote:
> How do you initialize values to use in a form?
> 
> I tried just initializing the value in the action and referencing it in the
> form, but the value is not set.
> 
> In action:
> 
> private String test = "tesing";
> 
> in form:
> 
> <s:textfield value="%{test}"/>

That should work fine, provided you have a getter for the 'test' 
property in your action.

In general, there is no equivalent of the Struts1 form bean reset() 
method in Struts2, since there's no need: the action and the form bean 
are the same thing, and get instantiated once per request.

L.


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