You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Brett Porter <bp...@f2network.com.au> on 2001/11/29 02:54:42 UTC

RE: Hidden Field in a form. Do I use struts taglib or vanilla ht ml?

That's an interesting design decision. I have always had a form bean and
then another bean containing the actual data. The action copies it across,
processes it, and stores it.

The reason I'd do it that way is that I imagine the message is a "business
class", and you don't really want you model "polluted" by extending an
ActionForm. Maybe I've been living in OOAD land too long though ;)

This can trip you up though - at least once I have added the form element,
added it to the bean, added it to the form bean, and forgetten to do the
setter in the action :) The way around that is probably a function in the
form bean that says "fill my business class" and "fill from a business
class". Actually, I might put that in my todo list :D

Cheers,
Brett

-----Original Message-----
From: antony@claire.co.jp [mailto:antony@claire.co.jp]
Sent: Thursday, 29 November 2001 12:48 PM
To: Struts Users Mailing List
Subject: Re: Hidden Field in a form. Do I use struts taglib or vanilla
ht ml?


The data I am storing in the bean is logically different from what the 
hidden field value is,  I have a message

message
{
   string  Recipent
   string  From
   string  MessageBode
}

And the hidden field is   action=sendMessage and I didn't think that

message
{
   string  Action
   string  Recipent
   string  From
   string  MessageBode
}

would be the correct thing to do, but I am open to suggestions.  If it 
works out easier to put this extra field in my message formbean then I 
will do it.  What do you think?

Cheers

Tony



Brett Porter wrote:

> The question I ask is why you wouldn't put it in your form bean?
> 
> I prefer form.getAction() over httpServletRequest.getParameter( "action" )
> any day! :)
> 
> -----Original Message-----
> From: Yee Keat [mailto:ykphuah@netwxs.com.my]
> Sent: Thursday, 29 November 2001 12:36 PM
> To: Struts Users Mailing List
> Subject: Re: Hidden Field in a form. Do I use struts taglib or vanilla
> html?
> 
> 
> Yup, using the taglib makes it compulsory to have that field in your
> FormBean
> 
> On Thursday 29 November 2001 09:25 am, you wrote:
> 
>>Hi
>>
>>I want to include a hidden field in a form which I have.  I do not want
>>this information to be included in the formbean which is defined for
>>this page.  How can I do this?  Should I just use plain html
>>
>><INPUT TYPE=hidden NAME=action VALUE=send>
>>
>>without using the html taglib supplied with struts?
>>
>>Cheers
>>
>>Tony
>>
> 




--
To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
For additional commands, e-mail:
<ma...@jakarta.apache.org>

struts and tomcat

Posted by Derek M Wayland <ma...@dmwayland.com>.
quick question:

i have tomcat 3.2.4 and want to run the example struts-example.war.

i have dropped this war file into the webapps directory and then restart
tomcat - it tries to run then closes. nothing
good in the log files either.

i have tomcat 4.0 and do the same, no problem, tomcat and struts-example
works well.

i need to get the example running in tomcat 3.2.4.

any help, i have tried almost everything now.


thanks in advance

...dmw


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Hidden Field in a form. Do I use struts taglib or vanilla html?

Posted by Erik Hatcher <ja...@ehatchersolutions.com>.
I believe Ted actually means 'reset()' instead of 'init()'.


----- Original Message -----
From: "Ted Husted" <hu...@apache.org>
To: "Struts Users Mailing List" <st...@jakarta.apache.org>
Sent: Thursday, November 29, 2001 11:15 AM
Subject: Re: Hidden Field in a form. Do I use struts taglib or vanilla html?


> In Struts 1.0.1, init() is called if the ActionForm is instantiated by
> the JavaServer Page. In Struts 1.0, this only happens when the
> ActionForm is instantiated by the ActionServlet. Of course, any default
> values assigned to the fields in the ActionForm class itself will be
> available in either case. The recommended control flow is to go through
> an Action first, and populate the ActionForm there. Populating the
> ActionForm from the JSP is a Model 1 strategy.
>
> -- Ted Husted, Husted dot Com, Fairport NY USA.
> -- Custom Software ~ Technical Services.
> -- Tel +1 716 737-3463
> -- http://www.husted.com/struts/
>
>
> David Lauta wrote:
> >
> > Is there a method in the framework that gets invoked allowing you to
> > initialize the ActionForm before the JSP is displayed?
> >
> > Brett Porter wrote:
> >
> > > That's an interesting design decision. I have always had a form bean
and
> > > then another bean containing the actual data. The action copies it
across,
> > > processes it, and stores it.
> > >
> > > The reason I'd do it that way is that I imagine the message is a
"business
> > > class", and you don't really want you model "polluted" by extending an
> > > ActionForm. Maybe I've been living in OOAD land too long though ;)
> > >
> > > This can trip you up though - at least once I have added the form
element,
> > > added it to the bean, added it to the form bean, and forgetten to do
the
> > > setter in the action :) The way around that is probably a function in
the
> > > form bean that says "fill my business class" and "fill from a business
> > > class". Actually, I might put that in my todo list :D
> > >
> > > Cheers,
> > > Brett
> > >
> > > -----Original Message-----
> > > From: antony@claire.co.jp [mailto:antony@claire.co.jp]
> > > Sent: Thursday, 29 November 2001 12:48 PM
> > > To: Struts Users Mailing List
> > > Subject: Re: Hidden Field in a form. Do I use struts taglib or vanilla
> > > ht ml?
> > >
> > > The data I am storing in the bean is logically different from what the
> > > hidden field value is,  I have a message
> > >
> > > message
> > > {
> > >    string  Recipent
> > >    string  From
> > >    string  MessageBode
> > > }
> > >
> > > And the hidden field is   action=sendMessage and I didn't think that
> > >
> > > message
> > > {
> > >    string  Action
> > >    string  Recipent
> > >    string  From
> > >    string  MessageBode
> > > }
> > >
> > > would be the correct thing to do, but I am open to suggestions.  If it
> > > works out easier to put this extra field in my message formbean then I
> > > will do it.  What do you think?
> > >
> > > Cheers
> > >
> > > Tony
> > >
> > > Brett Porter wrote:
> > >
> > > > The question I ask is why you wouldn't put it in your form bean?
> > > >
> > > > I prefer form.getAction() over httpServletRequest.getParameter(
"action" )
> > > > any day! :)
> > > >
> > > > -----Original Message-----
> > > > From: Yee Keat [mailto:ykphuah@netwxs.com.my]
> > > > Sent: Thursday, 29 November 2001 12:36 PM
> > > > To: Struts Users Mailing List
> > > > Subject: Re: Hidden Field in a form. Do I use struts taglib or
vanilla
> > > > html?
> > > >
> > > >
> > > > Yup, using the taglib makes it compulsory to have that field in your
> > > > FormBean
> > > >
> > > > On Thursday 29 November 2001 09:25 am, you wrote:
> > > >
> > > >>Hi
> > > >>
> > > >>I want to include a hidden field in a form which I have.  I do not
want
> > > >>this information to be included in the formbean which is defined for
> > > >>this page.  How can I do this?  Should I just use plain html
> > > >>
> > > >><INPUT TYPE=hidden NAME=action VALUE=send>
> > > >>
> > > >>without using the html taglib supplied with struts?
> > > >>
> > > >>Cheers
> > > >>
> > > >>Tony
> > > >>
> > > >
> > >
> > > --
> > > To unsubscribe, e-mail:
> > > <ma...@jakarta.apache.org>
> > > For additional commands, e-mail:
> > > <ma...@jakarta.apache.org>
> >
> > --
> > Thank you,
> > David Lauta
> > lautad@gate.net
> > (561)272-2698
> > (561)289-0502 cell
> >
> > --
> > To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
> > For additional commands, e-mail:
<ma...@jakarta.apache.org>
>
> --
> To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
> For additional commands, e-mail:
<ma...@jakarta.apache.org>
>
>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


HTTP form based authentication

Posted by Shri <sd...@gresham-computing.com.au>.
HI all,

When we follow HTTP form based authentication, for the form field we write:

<form method="POST" action="j_security_check">

( as per servlet specifications )

Using an action other than ".do" will break the action / action servlet
chain...

How to make this a part of action chain?

Any way of work around for this??

Shri

-----Original Message-----
From: Ted Husted [mailto:husted@apache.org]
Sent: Friday, 30 November 2001 8:19 AM
To: Struts Users Mailing List
Subject: Re: Hidden Field in a form. Do I use struts taglib or vanilla
html?


The cleanest thing is to put the ArrayList on the ActionForm. The syntax
of the options tag is suboptimal, so you need to expose the property as
a bean.

<html:select property="namesId">
<bean:define id="names" name="actionForm"
	property="names" type="java.util.Collection"/>
<html:options collection="names" property="value"
labelProperty="label"/>
</html:select>

So, you go through an Action, and have it setup the names list.

If there's validation involved, use the same Action as the input path,
so the list gets made again.

This also makes it much easier to retrieve the list from a database or
static class that is on the business tier.

David Lauta wrote:
>
> Wow,
> Thanks Ted this is great info.
>
> I have narrowed my problem down to:
> I want to use a <SELECT> Tag on a form and I want the options to be
> populated when the form is first displayed.
> To do this I need to set an ArrayList of valueLabel pairs in the page
Context
>
>  pageContext.setAttribute("names", actionForm.getNames());
> // getNames returns an ArrayList
> // each Item in the arrayList has a getValue() and getLabel() accessor.
> This works but is coded in the JSP ( tightly coupling the UI with the
Model ).
> I'm looking for a way to set the attribute outside of the JSP
> so that the following will work
>
>   <form:select
>    property="namesId"
>    onchange="javascript:submitForm()" >
>    <form:options collection="names" property="value" labelProperty="label"
/>
>   </form:select>
>
> In the sequence of events listed below when is the earliest that I can
obtain the
> pageContext
> to call the setAttribute() method on it. I'm guessing that the PageContext
of the JSP is
> the same as the
> ServletContext of the HTTPServlet
>
> Could my problem be related to I am using the ActionForm instead of the
ActionFormBean
> class?
>

--
To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
For additional commands, e-mail:
<ma...@jakarta.apache.org>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Hidden Field in a form. Do I use struts taglib or vanilla html?

Posted by Ted Husted <hu...@apache.org>.
The cleanest thing is to put the ArrayList on the ActionForm. The syntax
of the options tag is suboptimal, so you need to expose the property as
a bean. 

<html:select property="namesId">
<bean:define id="names" name="actionForm" 
	property="names" type="java.util.Collection"/>
<html:options collection="names" property="value"
labelProperty="label"/>
</html:select>

So, you go through an Action, and have it setup the names list. 

If there's validation involved, use the same Action as the input path,
so the list gets made again.

This also makes it much easier to retrieve the list from a database or
static class that is on the business tier.

David Lauta wrote:
> 
> Wow,
> Thanks Ted this is great info.
> 
> I have narrowed my problem down to:
> I want to use a <SELECT> Tag on a form and I want the options to be
> populated when the form is first displayed.
> To do this I need to set an ArrayList of valueLabel pairs in the page Context
> 
>  pageContext.setAttribute("names", actionForm.getNames());
> // getNames returns an ArrayList
> // each Item in the arrayList has a getValue() and getLabel() accessor.
> This works but is coded in the JSP ( tightly coupling the UI with the Model ).
> I'm looking for a way to set the attribute outside of the JSP
> so that the following will work
> 
>   <form:select
>    property="namesId"
>    onchange="javascript:submitForm()" >
>    <form:options collection="names" property="value" labelProperty="label" />
>   </form:select>
> 
> In the sequence of events listed below when is the earliest that I can obtain the
> pageContext
> to call the setAttribute() method on it. I'm guessing that the PageContext of the JSP is
> the same as the
> ServletContext of the HTTPServlet
> 
> Could my problem be related to I am using the ActionForm instead of the ActionFormBean
> class?
>

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Hidden Field in a form. Do I use struts taglib or vanilla html?

Posted by David Lauta <la...@gate.net>.
Wow,
Thanks Ted this is great info.

I have narrowed my problem down to:
I want to use a <SELECT> Tag on a form and I want the options to be
populated when the form is first displayed.
To do this I need to set an ArrayList of valueLabel pairs in the page Context

 pageContext.setAttribute("names", actionForm.getNames());
// getNames returns an ArrayList
// each Item in the arrayList has a getValue() and getLabel() accessor.
This works but is coded in the JSP ( tightly coupling the UI with the Model ).
I'm looking for a way to set the attribute outside of the JSP
so that the following will work

  <form:select
   property="namesId"
   onchange="javascript:submitForm()" >
   <form:options collection="names" property="value" labelProperty="label" />
  </form:select>

In the sequence of events listed below when is the earliest that I can obtain the
pageContext
to call the setAttribute() method on it. I'm guessing that the PageContext of the JSP is
the same as the
ServletContext of the HTTPServlet

Could my problem be related to I am using the ActionForm instead of the ActionFormBean
class?


Ted Husted wrote:

> The general order of things is
>
> 1) Client requests an Action URI (the path from the ActionMapping)
> 2) The container passes the request to the ActionServlet
> 3) The ActionServlet looks up the mapping for the path
> 4) If the mapping specifies a form bean, the ActionServlet sees if there
> is one already, or creates one.
> 4.1) If a form bean is in play, the ActionServlet resets and populates
> it from the HTTP request
> 4.2) If the mapping has validate set to true, it calls validate on the
> form bean. If it fails, it forwards to the path specified by the input
> property, and this control flow ends
> 5) If the mapping specifies an Action type, it is instantiated if
> needed, or reused if already there
> 5.1) The Action's perform method is called, with the instantiated form
> bean
> 5.2) The Action may populate the form bean, call business objects,and do
> whatever else is needed
> 5.3) The Action returns an ActionForward to the ActionServlet
>
> If the ActionForward is to another Action URI, we begin again, else it's
> off to a JSP or something.
>
> If the ActionForward is to a JSP
> 1) Jasper, or the equivalent, renders the page
> 2) If the Struts html tags see the ActionForm in the request (from 4),
> it populate the controls from the ActionForm. Else the html:form tag
> creates one, and uses its default values in its tags.
>
> (Can't draw, but I sure can number;-)
>
> If you just need to create a blank form (4), you can use a "continue
> Action" to pass control through an Action and then out to the JSP.
>
>     public ActionForward perform(ActionMapping mapping,
>                  ActionForm form,
>                  HttpServletRequest request,
>                  HttpServletResponse response)
>     throws IOException, ServletException {
>
>         return mapping.findForward(request.getParameter("continue"));
>
>     }
>
> So in the mapping you specify the ActionForm for this instance,
> validate=false, and a local forward for the JSP input form.
>
> David Lauta wrote:
> >
> > Thanks for the reply,
> > I understand that you would like me to seperate the UI from the Model
> > Can you be more specific about
> >     'The recommended control flow is to go through an Action first'
> > I'm trying to get a one page does it all UI - Is there a tag I should use to invoke
> > some kind
> > of preprocess action?
> >
> > What I am after is populating the List boxes with data from (ultimately) EJB's
> > I need to decide where I am going to instantiate and initialize my EJB's ( Session
> > Beans )
> >
> > To this point in my model I have subclassed ActionForm, Action, and ActionMapping
> > my struts-config.xml is:
> >  <form-beans>
> >   <form-bean
> >    name="StrutsTestForm"
> >    type="web.StrutsTestForm" />
> >  </form-beans>
> >
> >  <action-mappings>
> >   <action
> >    name="StrutsTestForm"
> >    path="/StrutsTest"
> >    type="web.StrutsTestAction"
> >    input="/StrutsTest.jsp"
> >    attribute="StrutsTestForm"   >
> >
> >    <forward name="success" path="/StrutsTest.jsp"  />
> >   </action>
> >
> >  </action-mappings>
> >
> > Should I be using the ActionFormBean instead or in conjunction with the ActionForm
> > subclass?
> > >From the ActionForm I can get the ActionMapping through
> > ActionServlet.findMapping(String)
> > At what point in time is the servlet associated with ActionForm valid.
> >
> > Most of my confusion comes from the order of things.
> > So far my model
> > 1 Create the ActionForm  ( Servlet is null )
> > 2 Initialize the JSP ( all form values are null )
> > 3 Get ActionMapping Name
> > 4 Get ActionMapping Name
> > 5 Create another ActionForm (Servlet is null)
> > 6 Some magic I haven't been able to trace yet
> > 7 The JSP appears and the list boxes are filled in
> >
> > It seems like I have two instances of ActionMapping and two instances of ActionForm
> >
> > How should the initialization really occur?
> >
> > Thanks for your attention
> > -David Lauta
> > lautad@gate.net
> >
> > Ted Husted wrote:
> >
> > > In Struts 1.0.1, init() is called if the ActionForm is instantiated by
> > > the JavaServer Page. In Struts 1.0, this only happens when the
> > > ActionForm is instantiated by the ActionServlet. Of course, any default
> > > values assigned to the fields in the ActionForm class itself will be
> > > available in either case. The recommended control flow is to go through
> > > an Action first, and populate the ActionForm there. Populating the
> > > ActionForm from the JSP is a Model 1 strategy.
> > >
> > > -- Ted Husted, Husted dot Com, Fairport NY USA.
> > > -- Custom Software ~ Technical Services.
> > > -- Tel +1 716 737-3463
> > > -- http://www.husted.com/struts/
> > >
> > > David Lauta wrote:
> > > >
> > > > Is there a method in the framework that gets invoked allowing you to
> > > > initialize the ActionForm before the JSP is displayed?
> > > >
> > > > Brett Porter wrote:
> > > >
> > > > > That's an interesting design decision. I have always had a form bean and
> > > > > then another bean containing the actual data. The action copies it across,
> > > > > processes it, and stores it.
> > > > >
> > > > > The reason I'd do it that way is that I imagine the message is a "business
> > > > > class", and you don't really want you model "polluted" by extending an
> > > > > ActionForm. Maybe I've been living in OOAD land too long though ;)
> > > > >
> > > > > This can trip you up though - at least once I have added the form element,
> > > > > added it to the bean, added it to the form bean, and forgetten to do the
> > > > > setter in the action :) The way around that is probably a function in the
> > > > > form bean that says "fill my business class" and "fill from a business
> > > > > class". Actually, I might put that in my todo list :D
> > > > >
> > > > > Cheers,
> > > > > Brett
> > > > >
> > > > > -----Original Message-----
> > > > > From: antony@claire.co.jp [mailto:antony@claire.co.jp]
> > > > > Sent: Thursday, 29 November 2001 12:48 PM
> > > > > To: Struts Users Mailing List
> > > > > Subject: Re: Hidden Field in a form. Do I use struts taglib or vanilla
> > > > > ht ml?
> > > > >
> > > > > The data I am storing in the bean is logically different from what the
> > > > > hidden field value is,  I have a message
> > > > >
> > > > > message
> > > > > {
> > > > >    string  Recipent
> > > > >    string  From
> > > > >    string  MessageBode
> > > > > }
> > > > >
> > > > > And the hidden field is   action=sendMessage and I didn't think that
> > > > >
> > > > > message
> > > > > {
> > > > >    string  Action
> > > > >    string  Recipent
> > > > >    string  From
> > > > >    string  MessageBode
> > > > > }
> > > > >
> > > > > would be the correct thing to do, but I am open to suggestions.  If it
> > > > > works out easier to put this extra field in my message formbean then I
> > > > > will do it.  What do you think?
> > > > >
> > > > > Cheers
> > > > >
> > > > > Tony
> > > > >
> > > > > Brett Porter wrote:
> > > > >
> > > > > > The question I ask is why you wouldn't put it in your form bean?
> > > > > >
> > > > > > I prefer form.getAction() over httpServletRequest.getParameter( "action" )
> > > > > > any day! :)
> > > > > >
> > > > > > -----Original Message-----
> > > > > > From: Yee Keat [mailto:ykphuah@netwxs.com.my]
> > > > > > Sent: Thursday, 29 November 2001 12:36 PM
> > > > > > To: Struts Users Mailing List
> > > > > > Subject: Re: Hidden Field in a form. Do I use struts taglib or vanilla
> > > > > > html?
> > > > > >
> > > > > >
> > > > > > Yup, using the taglib makes it compulsory to have that field in your
> > > > > > FormBean
> > > > > >
> > > > > > On Thursday 29 November 2001 09:25 am, you wrote:
> > > > > >
> > > > > >>Hi
> > > > > >>
> > > > > >>I want to include a hidden field in a form which I have.  I do not want
> > > > > >>this information to be included in the formbean which is defined for
> > > > > >>this page.  How can I do this?  Should I just use plain html
> > > > > >>
> > > > > >><INPUT TYPE=hidden NAME=action VALUE=send>
> > > > > >>
> > > > > >>without using the html taglib supplied with struts?
> > > > > >>
> > > > > >>Cheers
> > > > > >>
> > > > > >>Tony
> > > > > >>
> > > > > >
> > > > >
> > > > > --
> > > > > To unsubscribe, e-mail:
> > > > > <ma...@jakarta.apache.org>
> > > > > For additional commands, e-mail:
> > > > > <ma...@jakarta.apache.org>
> > > >
> > > > --
> > > > Thank you,
> > > > David Lauta
> > > > lautad@gate.net
> > > > (561)272-2698
> > > > (561)289-0502 cell
> > > >
> > > > --
> > > > To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> > > > For additional commands, e-mail: <ma...@jakarta.apache.org>
> > >
> > > --
> > > To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> > > For additional commands, e-mail: <ma...@jakarta.apache.org>
> >
> > --
> > Thank you,
> > David Lauta
> > lautad@gate.net
> > (561)272-2698
> > (561)289-0502 cell
> >
> > --
> > To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> > For additional commands, e-mail: <ma...@jakarta.apache.org>
>
> -- Ted Husted, Husted dot Com, Fairport NY USA.
> -- Custom Software ~ Technical Services.
> -- Tel +1 716 737-3463
> -- http://www.husted.com/struts/
>
> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>

--
Thank you,
David Lauta
lautad@gate.net
(561)272-2698
(561)289-0502 cell



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Hidden Field in a form. Do I use struts taglib or vanilla html?

Posted by David Lauta <la...@gate.net>.
WOW Thanks Ted thisis great info.

I have narrowed my problem down to:
I want to use a <SELECT> Tag on a form I want the options to be

Ted Husted wrote:

> The general order of things is
>
> 1) Client requests an Action URI (the path from the ActionMapping)
> 2) The container passes the request to the ActionServlet
> 3) The ActionServlet looks up the mapping for the path
> 4) If the mapping specifies a form bean, the ActionServlet sees if there
> is one already, or creates one.
> 4.1) If a form bean is in play, the ActionServlet resets and populates
> it from the HTTP request
> 4.2) If the mapping has validate set to true, it calls validate on the
> form bean. If it fails, it forwards to the path specified by the input
> property, and this control flow ends
> 5) If the mapping specifies an Action type, it is instantiated if
> needed, or reused if already there
> 5.1) The Action's perform method is called, with the instantiated form
> bean
> 5.2) The Action may populate the form bean, call business objects,and do
> whatever else is needed
> 5.3) The Action returns an ActionForward to the ActionServlet
>
> If the ActionForward is to another Action URI, we begin again, else it's
> off to a JSP or something.
>
> If the ActionForward is to a JSP
> 1) Jasper, or the equivalent, renders the page
> 2) If the Struts html tags see the ActionForm in the request (from 4),
> it populate the controls from the ActionForm. Else the html:form tag
> creates one, and uses its default values in its tags.
>
> (Can't draw, but I sure can number;-)
>
> If you just need to create a blank form (4), you can use a "continue
> Action" to pass control through an Action and then out to the JSP.
>
>     public ActionForward perform(ActionMapping mapping,
>                  ActionForm form,
>                  HttpServletRequest request,
>                  HttpServletResponse response)
>     throws IOException, ServletException {
>
>         return mapping.findForward(request.getParameter("continue"));
>
>     }
>
> So in the mapping you specify the ActionForm for this instance,
> validate=false, and a local forward for the JSP input form.
>
> David Lauta wrote:
> >
> > Thanks for the reply,
> > I understand that you would like me to seperate the UI from the Model
> > Can you be more specific about
> >     'The recommended control flow is to go through an Action first'
> > I'm trying to get a one page does it all UI - Is there a tag I should use to invoke
> > some kind
> > of preprocess action?
> >
> > What I am after is populating the List boxes with data from (ultimately) EJB's
> > I need to decide where I am going to instantiate and initialize my EJB's ( Session
> > Beans )
> >
> > To this point in my model I have subclassed ActionForm, Action, and ActionMapping
> > my struts-config.xml is:
> >  <form-beans>
> >   <form-bean
> >    name="StrutsTestForm"
> >    type="web.StrutsTestForm" />
> >  </form-beans>
> >
> >  <action-mappings>
> >   <action
> >    name="StrutsTestForm"
> >    path="/StrutsTest"
> >    type="web.StrutsTestAction"
> >    input="/StrutsTest.jsp"
> >    attribute="StrutsTestForm"   >
> >
> >    <forward name="success" path="/StrutsTest.jsp"  />
> >   </action>
> >
> >  </action-mappings>
> >
> > Should I be using the ActionFormBean instead or in conjunction with the ActionForm
> > subclass?
> > >From the ActionForm I can get the ActionMapping through
> > ActionServlet.findMapping(String)
> > At what point in time is the servlet associated with ActionForm valid.
> >
> > Most of my confusion comes from the order of things.
> > So far my model
> > 1 Create the ActionForm  ( Servlet is null )
> > 2 Initialize the JSP ( all form values are null )
> > 3 Get ActionMapping Name
> > 4 Get ActionMapping Name
> > 5 Create another ActionForm (Servlet is null)
> > 6 Some magic I haven't been able to trace yet
> > 7 The JSP appears and the list boxes are filled in
> >
> > It seems like I have two instances of ActionMapping and two instances of ActionForm
> >
> > How should the initialization really occur?
> >
> > Thanks for your attention
> > -David Lauta
> > lautad@gate.net
> >
> > Ted Husted wrote:
> >
> > > In Struts 1.0.1, init() is called if the ActionForm is instantiated by
> > > the JavaServer Page. In Struts 1.0, this only happens when the
> > > ActionForm is instantiated by the ActionServlet. Of course, any default
> > > values assigned to the fields in the ActionForm class itself will be
> > > available in either case. The recommended control flow is to go through
> > > an Action first, and populate the ActionForm there. Populating the
> > > ActionForm from the JSP is a Model 1 strategy.
> > >
> > > -- Ted Husted, Husted dot Com, Fairport NY USA.
> > > -- Custom Software ~ Technical Services.
> > > -- Tel +1 716 737-3463
> > > -- http://www.husted.com/struts/
> > >
> > > David Lauta wrote:
> > > >
> > > > Is there a method in the framework that gets invoked allowing you to
> > > > initialize the ActionForm before the JSP is displayed?
> > > >
> > > > Brett Porter wrote:
> > > >
> > > > > That's an interesting design decision. I have always had a form bean and
> > > > > then another bean containing the actual data. The action copies it across,
> > > > > processes it, and stores it.
> > > > >
> > > > > The reason I'd do it that way is that I imagine the message is a "business
> > > > > class", and you don't really want you model "polluted" by extending an
> > > > > ActionForm. Maybe I've been living in OOAD land too long though ;)
> > > > >
> > > > > This can trip you up though - at least once I have added the form element,
> > > > > added it to the bean, added it to the form bean, and forgetten to do the
> > > > > setter in the action :) The way around that is probably a function in the
> > > > > form bean that says "fill my business class" and "fill from a business
> > > > > class". Actually, I might put that in my todo list :D
> > > > >
> > > > > Cheers,
> > > > > Brett
> > > > >
> > > > > -----Original Message-----
> > > > > From: antony@claire.co.jp [mailto:antony@claire.co.jp]
> > > > > Sent: Thursday, 29 November 2001 12:48 PM
> > > > > To: Struts Users Mailing List
> > > > > Subject: Re: Hidden Field in a form. Do I use struts taglib or vanilla
> > > > > ht ml?
> > > > >
> > > > > The data I am storing in the bean is logically different from what the
> > > > > hidden field value is,  I have a message
> > > > >
> > > > > message
> > > > > {
> > > > >    string  Recipent
> > > > >    string  From
> > > > >    string  MessageBode
> > > > > }
> > > > >
> > > > > And the hidden field is   action=sendMessage and I didn't think that
> > > > >
> > > > > message
> > > > > {
> > > > >    string  Action
> > > > >    string  Recipent
> > > > >    string  From
> > > > >    string  MessageBode
> > > > > }
> > > > >
> > > > > would be the correct thing to do, but I am open to suggestions.  If it
> > > > > works out easier to put this extra field in my message formbean then I
> > > > > will do it.  What do you think?
> > > > >
> > > > > Cheers
> > > > >
> > > > > Tony
> > > > >
> > > > > Brett Porter wrote:
> > > > >
> > > > > > The question I ask is why you wouldn't put it in your form bean?
> > > > > >
> > > > > > I prefer form.getAction() over httpServletRequest.getParameter( "action" )
> > > > > > any day! :)
> > > > > >
> > > > > > -----Original Message-----
> > > > > > From: Yee Keat [mailto:ykphuah@netwxs.com.my]
> > > > > > Sent: Thursday, 29 November 2001 12:36 PM
> > > > > > To: Struts Users Mailing List
> > > > > > Subject: Re: Hidden Field in a form. Do I use struts taglib or vanilla
> > > > > > html?
> > > > > >
> > > > > >
> > > > > > Yup, using the taglib makes it compulsory to have that field in your
> > > > > > FormBean
> > > > > >
> > > > > > On Thursday 29 November 2001 09:25 am, you wrote:
> > > > > >
> > > > > >>Hi
> > > > > >>
> > > > > >>I want to include a hidden field in a form which I have.  I do not want
> > > > > >>this information to be included in the formbean which is defined for
> > > > > >>this page.  How can I do this?  Should I just use plain html
> > > > > >>
> > > > > >><INPUT TYPE=hidden NAME=action VALUE=send>
> > > > > >>
> > > > > >>without using the html taglib supplied with struts?
> > > > > >>
> > > > > >>Cheers
> > > > > >>
> > > > > >>Tony
> > > > > >>
> > > > > >
> > > > >
> > > > > --
> > > > > To unsubscribe, e-mail:
> > > > > <ma...@jakarta.apache.org>
> > > > > For additional commands, e-mail:
> > > > > <ma...@jakarta.apache.org>
> > > >
> > > > --
> > > > Thank you,
> > > > David Lauta
> > > > lautad@gate.net
> > > > (561)272-2698
> > > > (561)289-0502 cell
> > > >
> > > > --
> > > > To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> > > > For additional commands, e-mail: <ma...@jakarta.apache.org>
> > >
> > > --
> > > To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> > > For additional commands, e-mail: <ma...@jakarta.apache.org>
> >
> > --
> > Thank you,
> > David Lauta
> > lautad@gate.net
> > (561)272-2698
> > (561)289-0502 cell
> >
> > --
> > To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> > For additional commands, e-mail: <ma...@jakarta.apache.org>
>
> -- Ted Husted, Husted dot Com, Fairport NY USA.
> -- Custom Software ~ Technical Services.
> -- Tel +1 716 737-3463
> -- http://www.husted.com/struts/
>
> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>

--
Thank you,
David Lauta
lautad@gate.net
(561)272-2698
(561)289-0502 cell



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Hidden Field in a form. Do I use struts taglib or vanilla html?

Posted by Ted Husted <hu...@apache.org>.
The general order of things is 

1) Client requests an Action URI (the path from the ActionMapping)
2) The container passes the request to the ActionServlet
3) The ActionServlet looks up the mapping for the path
4) If the mapping specifies a form bean, the ActionServlet sees if there
is one already, or creates one.
4.1) If a form bean is in play, the ActionServlet resets and populates
it from the HTTP request
4.2) If the mapping has validate set to true, it calls validate on the
form bean. If it fails, it forwards to the path specified by the input
property, and this control flow ends
5) If the mapping specifies an Action type, it is instantiated if
needed, or reused if already there
5.1) The Action's perform method is called, with the instantiated form
bean
5.2) The Action may populate the form bean, call business objects,and do
whatever else is needed 
5.3) The Action returns an ActionForward to the ActionServlet

If the ActionForward is to another Action URI, we begin again, else it's
off to a JSP or something.

If the ActionForward is to a JSP
1) Jasper, or the equivalent, renders the page
2) If the Struts html tags see the ActionForm in the request (from 4),
it populate the controls from the ActionForm. Else the html:form tag
creates one, and uses its default values in its tags.

(Can't draw, but I sure can number;-)

If you just need to create a blank form (4), you can use a "continue
Action" to pass control through an Action and then out to the JSP. 

    public ActionForward perform(ActionMapping mapping,
                 ActionForm form,
                 HttpServletRequest request,
                 HttpServletResponse response)
    throws IOException, ServletException {

        return mapping.findForward(request.getParameter("continue"));

    }

So in the mapping you specify the ActionForm for this instance,
validate=false, and a local forward for the JSP input form.

David Lauta wrote:
> 
> Thanks for the reply,
> I understand that you would like me to seperate the UI from the Model
> Can you be more specific about
>     'The recommended control flow is to go through an Action first'
> I'm trying to get a one page does it all UI - Is there a tag I should use to invoke
> some kind
> of preprocess action?
> 
> What I am after is populating the List boxes with data from (ultimately) EJB's
> I need to decide where I am going to instantiate and initialize my EJB's ( Session
> Beans )
> 
> To this point in my model I have subclassed ActionForm, Action, and ActionMapping
> my struts-config.xml is:
>  <form-beans>
>   <form-bean
>    name="StrutsTestForm"
>    type="web.StrutsTestForm" />
>  </form-beans>
> 
>  <action-mappings>
>   <action
>    name="StrutsTestForm"
>    path="/StrutsTest"
>    type="web.StrutsTestAction"
>    input="/StrutsTest.jsp"
>    attribute="StrutsTestForm"   >
> 
>    <forward name="success" path="/StrutsTest.jsp"  />
>   </action>
> 
>  </action-mappings>
> 
> Should I be using the ActionFormBean instead or in conjunction with the ActionForm
> subclass?
> >From the ActionForm I can get the ActionMapping through
> ActionServlet.findMapping(String)
> At what point in time is the servlet associated with ActionForm valid.
> 
> Most of my confusion comes from the order of things.
> So far my model
> 1 Create the ActionForm  ( Servlet is null )
> 2 Initialize the JSP ( all form values are null )
> 3 Get ActionMapping Name
> 4 Get ActionMapping Name
> 5 Create another ActionForm (Servlet is null)
> 6 Some magic I haven't been able to trace yet
> 7 The JSP appears and the list boxes are filled in
> 
> It seems like I have two instances of ActionMapping and two instances of ActionForm
> 
> How should the initialization really occur?
> 
> Thanks for your attention
> -David Lauta
> lautad@gate.net
> 
> Ted Husted wrote:
> 
> > In Struts 1.0.1, init() is called if the ActionForm is instantiated by
> > the JavaServer Page. In Struts 1.0, this only happens when the
> > ActionForm is instantiated by the ActionServlet. Of course, any default
> > values assigned to the fields in the ActionForm class itself will be
> > available in either case. The recommended control flow is to go through
> > an Action first, and populate the ActionForm there. Populating the
> > ActionForm from the JSP is a Model 1 strategy.
> >
> > -- Ted Husted, Husted dot Com, Fairport NY USA.
> > -- Custom Software ~ Technical Services.
> > -- Tel +1 716 737-3463
> > -- http://www.husted.com/struts/
> >
> > David Lauta wrote:
> > >
> > > Is there a method in the framework that gets invoked allowing you to
> > > initialize the ActionForm before the JSP is displayed?
> > >
> > > Brett Porter wrote:
> > >
> > > > That's an interesting design decision. I have always had a form bean and
> > > > then another bean containing the actual data. The action copies it across,
> > > > processes it, and stores it.
> > > >
> > > > The reason I'd do it that way is that I imagine the message is a "business
> > > > class", and you don't really want you model "polluted" by extending an
> > > > ActionForm. Maybe I've been living in OOAD land too long though ;)
> > > >
> > > > This can trip you up though - at least once I have added the form element,
> > > > added it to the bean, added it to the form bean, and forgetten to do the
> > > > setter in the action :) The way around that is probably a function in the
> > > > form bean that says "fill my business class" and "fill from a business
> > > > class". Actually, I might put that in my todo list :D
> > > >
> > > > Cheers,
> > > > Brett
> > > >
> > > > -----Original Message-----
> > > > From: antony@claire.co.jp [mailto:antony@claire.co.jp]
> > > > Sent: Thursday, 29 November 2001 12:48 PM
> > > > To: Struts Users Mailing List
> > > > Subject: Re: Hidden Field in a form. Do I use struts taglib or vanilla
> > > > ht ml?
> > > >
> > > > The data I am storing in the bean is logically different from what the
> > > > hidden field value is,  I have a message
> > > >
> > > > message
> > > > {
> > > >    string  Recipent
> > > >    string  From
> > > >    string  MessageBode
> > > > }
> > > >
> > > > And the hidden field is   action=sendMessage and I didn't think that
> > > >
> > > > message
> > > > {
> > > >    string  Action
> > > >    string  Recipent
> > > >    string  From
> > > >    string  MessageBode
> > > > }
> > > >
> > > > would be the correct thing to do, but I am open to suggestions.  If it
> > > > works out easier to put this extra field in my message formbean then I
> > > > will do it.  What do you think?
> > > >
> > > > Cheers
> > > >
> > > > Tony
> > > >
> > > > Brett Porter wrote:
> > > >
> > > > > The question I ask is why you wouldn't put it in your form bean?
> > > > >
> > > > > I prefer form.getAction() over httpServletRequest.getParameter( "action" )
> > > > > any day! :)
> > > > >
> > > > > -----Original Message-----
> > > > > From: Yee Keat [mailto:ykphuah@netwxs.com.my]
> > > > > Sent: Thursday, 29 November 2001 12:36 PM
> > > > > To: Struts Users Mailing List
> > > > > Subject: Re: Hidden Field in a form. Do I use struts taglib or vanilla
> > > > > html?
> > > > >
> > > > >
> > > > > Yup, using the taglib makes it compulsory to have that field in your
> > > > > FormBean
> > > > >
> > > > > On Thursday 29 November 2001 09:25 am, you wrote:
> > > > >
> > > > >>Hi
> > > > >>
> > > > >>I want to include a hidden field in a form which I have.  I do not want
> > > > >>this information to be included in the formbean which is defined for
> > > > >>this page.  How can I do this?  Should I just use plain html
> > > > >>
> > > > >><INPUT TYPE=hidden NAME=action VALUE=send>
> > > > >>
> > > > >>without using the html taglib supplied with struts?
> > > > >>
> > > > >>Cheers
> > > > >>
> > > > >>Tony
> > > > >>
> > > > >
> > > >
> > > > --
> > > > To unsubscribe, e-mail:
> > > > <ma...@jakarta.apache.org>
> > > > For additional commands, e-mail:
> > > > <ma...@jakarta.apache.org>
> > >
> > > --
> > > Thank you,
> > > David Lauta
> > > lautad@gate.net
> > > (561)272-2698
> > > (561)289-0502 cell
> > >
> > > --
> > > To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> > > For additional commands, e-mail: <ma...@jakarta.apache.org>
> >
> > --
> > To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> > For additional commands, e-mail: <ma...@jakarta.apache.org>
> 
> --
> Thank you,
> David Lauta
> lautad@gate.net
> (561)272-2698
> (561)289-0502 cell
> 
> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>

-- Ted Husted, Husted dot Com, Fairport NY USA.
-- Custom Software ~ Technical Services.
-- Tel +1 716 737-3463
-- http://www.husted.com/struts/

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Hidden Field in a form. Do I use struts taglib or vanilla html?

Posted by David Lauta <la...@gate.net>.
Thanks for the reply,
I understand that you would like me to seperate the UI from the Model
Can you be more specific about
    'The recommended control flow is to go through an Action first'
I'm trying to get a one page does it all UI - Is there a tag I should use to invoke
some kind
of preprocess action?

What I am after is populating the List boxes with data from (ultimately) EJB's
I need to decide where I am going to instantiate and initialize my EJB's ( Session
Beans )

To this point in my model I have subclassed ActionForm, Action, and ActionMapping
my struts-config.xml is:
 <form-beans>
  <form-bean
   name="StrutsTestForm"
   type="web.StrutsTestForm" />
 </form-beans>

 <action-mappings>
  <action
   name="StrutsTestForm"
   path="/StrutsTest"
   type="web.StrutsTestAction"
   input="/StrutsTest.jsp"
   attribute="StrutsTestForm"   >

   <forward name="success" path="/StrutsTest.jsp"  />
  </action>

 </action-mappings>


Should I be using the ActionFormBean instead or in conjunction with the ActionForm
subclass?
>From the ActionForm I can get the ActionMapping through
ActionServlet.findMapping(String)
At what point in time is the servlet associated with ActionForm valid.

Most of my confusion comes from the order of things.
So far my model
1 Create the ActionForm  ( Servlet is null )
2 Initialize the JSP ( all form values are null )
3 Get ActionMapping Name
4 Get ActionMapping Name
5 Create another ActionForm (Servlet is null)
6 Some magic I haven't been able to trace yet
7 The JSP appears and the list boxes are filled in


It seems like I have two instances of ActionMapping and two instances of ActionForm

How should the initialization really occur?


Thanks for your attention
-David Lauta
lautad@gate.net

Ted Husted wrote:

> In Struts 1.0.1, init() is called if the ActionForm is instantiated by
> the JavaServer Page. In Struts 1.0, this only happens when the
> ActionForm is instantiated by the ActionServlet. Of course, any default
> values assigned to the fields in the ActionForm class itself will be
> available in either case. The recommended control flow is to go through
> an Action first, and populate the ActionForm there. Populating the
> ActionForm from the JSP is a Model 1 strategy.
>
> -- Ted Husted, Husted dot Com, Fairport NY USA.
> -- Custom Software ~ Technical Services.
> -- Tel +1 716 737-3463
> -- http://www.husted.com/struts/
>
> David Lauta wrote:
> >
> > Is there a method in the framework that gets invoked allowing you to
> > initialize the ActionForm before the JSP is displayed?
> >
> > Brett Porter wrote:
> >
> > > That's an interesting design decision. I have always had a form bean and
> > > then another bean containing the actual data. The action copies it across,
> > > processes it, and stores it.
> > >
> > > The reason I'd do it that way is that I imagine the message is a "business
> > > class", and you don't really want you model "polluted" by extending an
> > > ActionForm. Maybe I've been living in OOAD land too long though ;)
> > >
> > > This can trip you up though - at least once I have added the form element,
> > > added it to the bean, added it to the form bean, and forgetten to do the
> > > setter in the action :) The way around that is probably a function in the
> > > form bean that says "fill my business class" and "fill from a business
> > > class". Actually, I might put that in my todo list :D
> > >
> > > Cheers,
> > > Brett
> > >
> > > -----Original Message-----
> > > From: antony@claire.co.jp [mailto:antony@claire.co.jp]
> > > Sent: Thursday, 29 November 2001 12:48 PM
> > > To: Struts Users Mailing List
> > > Subject: Re: Hidden Field in a form. Do I use struts taglib or vanilla
> > > ht ml?
> > >
> > > The data I am storing in the bean is logically different from what the
> > > hidden field value is,  I have a message
> > >
> > > message
> > > {
> > >    string  Recipent
> > >    string  From
> > >    string  MessageBode
> > > }
> > >
> > > And the hidden field is   action=sendMessage and I didn't think that
> > >
> > > message
> > > {
> > >    string  Action
> > >    string  Recipent
> > >    string  From
> > >    string  MessageBode
> > > }
> > >
> > > would be the correct thing to do, but I am open to suggestions.  If it
> > > works out easier to put this extra field in my message formbean then I
> > > will do it.  What do you think?
> > >
> > > Cheers
> > >
> > > Tony
> > >
> > > Brett Porter wrote:
> > >
> > > > The question I ask is why you wouldn't put it in your form bean?
> > > >
> > > > I prefer form.getAction() over httpServletRequest.getParameter( "action" )
> > > > any day! :)
> > > >
> > > > -----Original Message-----
> > > > From: Yee Keat [mailto:ykphuah@netwxs.com.my]
> > > > Sent: Thursday, 29 November 2001 12:36 PM
> > > > To: Struts Users Mailing List
> > > > Subject: Re: Hidden Field in a form. Do I use struts taglib or vanilla
> > > > html?
> > > >
> > > >
> > > > Yup, using the taglib makes it compulsory to have that field in your
> > > > FormBean
> > > >
> > > > On Thursday 29 November 2001 09:25 am, you wrote:
> > > >
> > > >>Hi
> > > >>
> > > >>I want to include a hidden field in a form which I have.  I do not want
> > > >>this information to be included in the formbean which is defined for
> > > >>this page.  How can I do this?  Should I just use plain html
> > > >>
> > > >><INPUT TYPE=hidden NAME=action VALUE=send>
> > > >>
> > > >>without using the html taglib supplied with struts?
> > > >>
> > > >>Cheers
> > > >>
> > > >>Tony
> > > >>
> > > >
> > >
> > > --
> > > To unsubscribe, e-mail:
> > > <ma...@jakarta.apache.org>
> > > For additional commands, e-mail:
> > > <ma...@jakarta.apache.org>
> >
> > --
> > Thank you,
> > David Lauta
> > lautad@gate.net
> > (561)272-2698
> > (561)289-0502 cell
> >
> > --
> > To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> > For additional commands, e-mail: <ma...@jakarta.apache.org>
>
> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>

--
Thank you,
David Lauta
lautad@gate.net
(561)272-2698
(561)289-0502 cell



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Hidden Field in a form. Do I use struts taglib or vanilla html?

Posted by Ted Husted <hu...@apache.org>.
In Struts 1.0.1, init() is called if the ActionForm is instantiated by
the JavaServer Page. In Struts 1.0, this only happens when the
ActionForm is instantiated by the ActionServlet. Of course, any default
values assigned to the fields in the ActionForm class itself will be
available in either case. The recommended control flow is to go through
an Action first, and populate the ActionForm there. Populating the
ActionForm from the JSP is a Model 1 strategy.

-- Ted Husted, Husted dot Com, Fairport NY USA.
-- Custom Software ~ Technical Services.
-- Tel +1 716 737-3463
-- http://www.husted.com/struts/


David Lauta wrote:
> 
> Is there a method in the framework that gets invoked allowing you to
> initialize the ActionForm before the JSP is displayed?
> 
> Brett Porter wrote:
> 
> > That's an interesting design decision. I have always had a form bean and
> > then another bean containing the actual data. The action copies it across,
> > processes it, and stores it.
> >
> > The reason I'd do it that way is that I imagine the message is a "business
> > class", and you don't really want you model "polluted" by extending an
> > ActionForm. Maybe I've been living in OOAD land too long though ;)
> >
> > This can trip you up though - at least once I have added the form element,
> > added it to the bean, added it to the form bean, and forgetten to do the
> > setter in the action :) The way around that is probably a function in the
> > form bean that says "fill my business class" and "fill from a business
> > class". Actually, I might put that in my todo list :D
> >
> > Cheers,
> > Brett
> >
> > -----Original Message-----
> > From: antony@claire.co.jp [mailto:antony@claire.co.jp]
> > Sent: Thursday, 29 November 2001 12:48 PM
> > To: Struts Users Mailing List
> > Subject: Re: Hidden Field in a form. Do I use struts taglib or vanilla
> > ht ml?
> >
> > The data I am storing in the bean is logically different from what the
> > hidden field value is,  I have a message
> >
> > message
> > {
> >    string  Recipent
> >    string  From
> >    string  MessageBode
> > }
> >
> > And the hidden field is   action=sendMessage and I didn't think that
> >
> > message
> > {
> >    string  Action
> >    string  Recipent
> >    string  From
> >    string  MessageBode
> > }
> >
> > would be the correct thing to do, but I am open to suggestions.  If it
> > works out easier to put this extra field in my message formbean then I
> > will do it.  What do you think?
> >
> > Cheers
> >
> > Tony
> >
> > Brett Porter wrote:
> >
> > > The question I ask is why you wouldn't put it in your form bean?
> > >
> > > I prefer form.getAction() over httpServletRequest.getParameter( "action" )
> > > any day! :)
> > >
> > > -----Original Message-----
> > > From: Yee Keat [mailto:ykphuah@netwxs.com.my]
> > > Sent: Thursday, 29 November 2001 12:36 PM
> > > To: Struts Users Mailing List
> > > Subject: Re: Hidden Field in a form. Do I use struts taglib or vanilla
> > > html?
> > >
> > >
> > > Yup, using the taglib makes it compulsory to have that field in your
> > > FormBean
> > >
> > > On Thursday 29 November 2001 09:25 am, you wrote:
> > >
> > >>Hi
> > >>
> > >>I want to include a hidden field in a form which I have.  I do not want
> > >>this information to be included in the formbean which is defined for
> > >>this page.  How can I do this?  Should I just use plain html
> > >>
> > >><INPUT TYPE=hidden NAME=action VALUE=send>
> > >>
> > >>without using the html taglib supplied with struts?
> > >>
> > >>Cheers
> > >>
> > >>Tony
> > >>
> > >
> >
> > --
> > To unsubscribe, e-mail:
> > <ma...@jakarta.apache.org>
> > For additional commands, e-mail:
> > <ma...@jakarta.apache.org>
> 
> --
> Thank you,
> David Lauta
> lautad@gate.net
> (561)272-2698
> (561)289-0502 cell
> 
> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Hidden Field in a form. Do I use struts taglib or vanilla html?

Posted by David Lauta <la...@gate.net>.
Is there a method in the framework that gets invoked allowing you to
initialize the ActionForm before the JSP is displayed?


Brett Porter wrote:

> That's an interesting design decision. I have always had a form bean and
> then another bean containing the actual data. The action copies it across,
> processes it, and stores it.
>
> The reason I'd do it that way is that I imagine the message is a "business
> class", and you don't really want you model "polluted" by extending an
> ActionForm. Maybe I've been living in OOAD land too long though ;)
>
> This can trip you up though - at least once I have added the form element,
> added it to the bean, added it to the form bean, and forgetten to do the
> setter in the action :) The way around that is probably a function in the
> form bean that says "fill my business class" and "fill from a business
> class". Actually, I might put that in my todo list :D
>
> Cheers,
> Brett
>
> -----Original Message-----
> From: antony@claire.co.jp [mailto:antony@claire.co.jp]
> Sent: Thursday, 29 November 2001 12:48 PM
> To: Struts Users Mailing List
> Subject: Re: Hidden Field in a form. Do I use struts taglib or vanilla
> ht ml?
>
> The data I am storing in the bean is logically different from what the
> hidden field value is,  I have a message
>
> message
> {
>    string  Recipent
>    string  From
>    string  MessageBode
> }
>
> And the hidden field is   action=sendMessage and I didn't think that
>
> message
> {
>    string  Action
>    string  Recipent
>    string  From
>    string  MessageBode
> }
>
> would be the correct thing to do, but I am open to suggestions.  If it
> works out easier to put this extra field in my message formbean then I
> will do it.  What do you think?
>
> Cheers
>
> Tony
>
> Brett Porter wrote:
>
> > The question I ask is why you wouldn't put it in your form bean?
> >
> > I prefer form.getAction() over httpServletRequest.getParameter( "action" )
> > any day! :)
> >
> > -----Original Message-----
> > From: Yee Keat [mailto:ykphuah@netwxs.com.my]
> > Sent: Thursday, 29 November 2001 12:36 PM
> > To: Struts Users Mailing List
> > Subject: Re: Hidden Field in a form. Do I use struts taglib or vanilla
> > html?
> >
> >
> > Yup, using the taglib makes it compulsory to have that field in your
> > FormBean
> >
> > On Thursday 29 November 2001 09:25 am, you wrote:
> >
> >>Hi
> >>
> >>I want to include a hidden field in a form which I have.  I do not want
> >>this information to be included in the formbean which is defined for
> >>this page.  How can I do this?  Should I just use plain html
> >>
> >><INPUT TYPE=hidden NAME=action VALUE=send>
> >>
> >>without using the html taglib supplied with struts?
> >>
> >>Cheers
> >>
> >>Tony
> >>
> >
>
> --
> To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
> For additional commands, e-mail:
> <ma...@jakarta.apache.org>

--
Thank you,
David Lauta
lautad@gate.net
(561)272-2698
(561)289-0502 cell



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Hidden Field in a form. Do I use struts taglib or vanilla html?

Posted by Ted Husted <hu...@apache.org>.
Brett Porter wrote:
> This can trip you up though - at least once I have added the form element,
> added it to the bean, added it to the form bean, and forgetten to do the
> setter in the action :) The way around that is probably a function in the
> form bean that says "fill my business class" and "fill from a business
> class". Actually, I might put that in my todo list :D

If it helps, here are some methods that do that using reflection. Set
fills this object from another object. Populate fills another object
from this object. I have the luxury of placing these on my base business
class, but, given comparable exceptions, they would work just as well on
an ActionForm. (Hmmm.)

    public void set(Object o) throws ModelException {
        try {
            BeanUtils.populate(this,BeanUtils.describe(o));
        } catch (Throwable t) {
            throw new ModelPopulateException(t);
      }
    };

    public void populate(Object o) throws ModelException {
        try {
            BeanUtils.populate(o,BeanUtils.describe(this));
        } catch (Throwable t) {
            throw new ModelPopulateException(t);
      }
    }

If there were a mismatch between the property names, one way around that
would be to replace the call to BeanUtils.describe withy a custom
version that generated the appropriate hashmap for the target bean.

-- Ted Husted, Husted dot Com, Fairport NY USA.
-- Custom Software ~ Technical Services.
-- Tel +1 716 737-3463
-- http://www.husted.com/struts/

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>