Re: Populating a Form with values

2002-07-24 Thread Sid Stuart

Hi all,

I also initially wrote two action classes for each JSP page, one to 
intialize it and the other to process the form. This got a bit messy, so 
I wrote template that looks at the HTTP method and calls an 
initialization method if it is a "GET" or calls a form processing method 
if it is "POST". A class extending the template can be used both to 
initialize the form needed by a JSP page as well as process the form. An 
excerpt of the code is below.

Sid

public abstract class ActionTemplate extends Action {

private final String GET = "GET";
private final String POST = "POST";

//- 
Public Methods
/**
 * Override the Action method's perform method. This looks at the 
HTTP method used to initiate the
 * transaction and calls one of two abstract methods, depending on 
whether a get or post
 * was sent.
 *
 * @return An ActionForward object.
 */
public ActionForward perform(ActionMapping mapping, ActionForm form,
 HttpServletRequest request, 
HttpServletResponse response)   {
log.info ("Entering perform:");
// The result is returned at the end.
ActionForward result = null;

// Get the session
final HttpSession session = request.getSession ();

// At this point, the perform method calls one of two abstract 
methods.
// One does initialization and displays the JSP page. The other 
processes
// a form submitted by the JSP page. Which method to call is 
decided by whether the
// action was initiated by a get or a post.
//
final String method = request.getMethod ();
// Initialize a JSP page.
if (method.compareToIgnoreCase(GET) == 0 ) {
result = initializeJSP (mapping, form, request, response, 
session);
}
// Process a form.
else if (method.compareToIgnoreCase(POST) == 0) {
result = processForm (mapping, form, request, response, 
session);
}
else {
log.error("Unknown method received by Action: " + method);
}
log.info ("Leaving perform");
return result;
  }



//--- 
Abstract Methods
/**
 * The initializeJSP method is called before the JSP page is 
displayed. It should
 * initialize any objects needed by the page.
 * @return An ActionForward object
 */
protected abstract ActionForward initializeJSP (ActionMapping 
mapping, ActionForm form,
 HttpServletRequest request, HttpServletResponse response, 
HttpSession session);

/**
 * The processForm method is called when the form is submitted from 
the JSP page. It should contain
 * the code needed to process the form.
 * @return An ActionForward object
 */
 protected abstract ActionForward processForm (ActionMapping 
mapping, ActionForm form,
  HttpServletRequest request,  HttpServletResponse response, 
HttpSession session);
}


Keith Bacon wrote:

>Most people say best practice is to always start your jsp from the struts action. 
>(always use the
>/myAction.do not /myAction.jsp).
>
>I think you need to do a lot of studying & messing around to get the hang of struts, 
>it's not
>totally simple - but web apps never were.
>Try http://husted.com/struts/resources.htm
>
>Keith.
>  
>




--
To unsubscribe, e-mail:   
For additional commands, e-mail: 




RE: Populating a Form with values

2002-01-11 Thread Jesse Alexander (KABS 11)

I also prefer 1 action... but I use the parameter-tag in struts-config for the 
action-mapping. Meaning 2 ActionMappings - 1 Action - 1 ActionForm and so on

regards
Alexander

-Original Message-
From: Keith Bacon [mailto:[EMAIL PROTECTED]]
Sent: Donnerstag, 10. Januar 2002 19:04
To: Struts Users Mailing List
Subject: RE: Populating a Form with values


For init population put the data in the form bean passed into your perform method, the 
struts tags
in your form will get the values out of the form automatically for you.

> Am I missing something?
nope - you've got it sussed. Some do it your way which I suspect might be 
theoretically better
design - it makes it easier to split  the Action into 2 if required.
Some (like me) do it with 1 action. I have a hidden field hard coded on the form. If 
this is
received I know the form was submitted.
Hope this helps - Keith.

--- "Witt, Mike (OH35)" <[EMAIL PROTECTED]> wrote:
> I was talking about populating the form with information from the database
> so the user can update the data.  What you are saying is that if you did
> this work upfront and set the parameters with values for the field, it would
> populate the form bean automatically if the names match.
> 
> What I have been doing is to use a form and an action, but two action
> mappings for this type of thing.  The first action mapping has a parameter
> of "initialize" and I go and get the data and put it on the form.  The
> second action mapping has a paramater called "update" and I take the data
> from the form, using the form bean and update the database.  Am I missing
> something?
> 
> Mike
> 
> -Original Message-
> From: Keith Bacon [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, January 10, 2002 10:11 AM
> To: Struts Users Mailing List
> Subject: RE: Populating a Form with values
> 
> 
> I think you've missed the point of form beans.
> On submission of an html form struts looks at the request parameters. If it
> can find a matching
> set method in the form bean it calls it. ie. the form parms are copied into
> the form bean.
> 
> When you forward to a jsp with a form struts calls the get methods of the
> form bean to populate
> the the matching form fields (that have been defined with struts tags).
> 
> You action class can deal with the form variables by calling the same
> get/set methods of the form
> bean. This saves doing qqq = request.getParameter("qqq"); & testing for
> nulls etc.
> 
> That's the whole point of form beans - to manage form fields.
> 
> To get readonly data onto your jsp your action class should place it in the
> request where the jsp
> can get at it easily.
> 
> Keith.
> 
> 
> 
> 
> 
> --- "Witt, Mike (OH35)" <[EMAIL PROTECTED]> wrote:
> > I'm new to struts also, but the way I have been doing it is to set up an
> > action and a form bean in the struts config.  The action code (or some
> other
> > bean that the action code uses) for getting the data from the database and
> > populating the form using something like
> > (MyForm)form.setField(theFieldData);
> > 
> > Hope this helps.
> > 
> > Mike
> > 
> > -Original Message-
> > From: Daniel Jaffa [mailto:[EMAIL PROTECTED]]
> > Sent: Thursday, January 10, 2002 9:25 AM
> > To: [EMAIL PROTECTED]
> > Subject: Populating a Form with values
> > 
> > 
> > I am new to struts so be nice (But i have worked with jsp for 2 years).  I
> 
> > have a form that i need to populate a form with values from the database.
> I
> > 
> > pass the form a data_base id to the form but i now need the form to
> populate
> > 
> > the formbean.  I know how to do this in jsp but i want to do the in the 
> > struts way.
> > 
> > _
> > MSN Photos is the easiest way to share and print your photos: 
> > http://photos.msn.com/support/worldwide.aspx
> > 
> > 
> > --
> > To unsubscribe, e-mail:
> > <mailto:[EMAIL PROTECTED]>
> > For additional commands, e-mail:
> > <mailto:[EMAIL PROTECTED]>
> > 
> > --
> > To unsubscribe, e-mail:
> <mailto:[EMAIL PROTECTED]>
> > For additional commands, e-mail:
> <mailto:[EMAIL PROTECTED]>
> > 
> 
> 
> __
> Do You Yahoo!?
> Send FREE video emails in Yahoo! Mail!
> http://promo.yahoo.com/videomail/
> 
> --
> To unsubscribe, e-mail:
> <mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail:
> <mailto:[EMAIL PROTECTED]>
> 
> --
> To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
> 


__
Do You Yahoo!?
Send FREE video emails in Yahoo! Mail!
http://promo.yahoo.com/videomail/

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>




RE: Populating a Form with values

2002-01-10 Thread Keith Bacon

This is my understanding of the roles Of ActionForm & Action classes & Business logic 
& the best
way to use them in a typical business system. It's in as plain English as I can manage.
Quite a lot of experimentation has gone into all this but I'm way less experienced at 
struts than
many on the list. I hope this helps the students & beginners.

Actionform (also called form bean)
-
Designed to simplify the transferring data to & from html forms. Also pre-validation 
can be
defined (in validate method) but I avoid this (validate="false" in struts-config). One 
set of
validation code in the business logic & none anywhere else is simplest (I hate 
duplicated code
with a passion!).

Action
--

Action logic if inital display being done
1 - fetch the data from DB (tiny system), from business class (medium sized system), 
or some sort
of facade class that fetches it from the business class (mega-monster super 
architected EJB
system)
2 - move data to form bean & forward to the jsp (struts form tags will get their data 
from the
form bean).
3 - fetch other data required by the jsp & place it in the request (such as lists of 
states for a
select box). An alternative is custom tags (or scriplets) on the jsp that fetch & 
display things
like this. I prefer to do it the 1st way & never any other as this is all fiddly 
anyway - the
fewer design patterns used the better.
4 - If you have data in the session still don't let the jsp get it from there, you may 
move it
elsewhere one day. It's a simple pattern to know your jsps only display what the 
Action class
presents to them. (I could be argued out of this!).

Action logic if validation being done
- get data from the form bean & shove it at the business class that validates it. the 
form bean
only has String versions of the data as this is what HTML uses. So your validation 
logic must
accept String input. 
- possibly re-set the value in the form bean from the validation class (it may have 
standardised
it's format or cleaned it up ie. user types +123.4 you re-display it as 123.40). I 
think the
business class should return the displayable format of numeric data too.

if form data valid
- tell the business class to save it & go to success action.
else
- move validation errors (in Errors object) to the request & forward to our form, so 
user can
correct errors.

My design pattern for Business Logic Validation
---
These handle String input, even for numeric data (method overloading yay!). I have 
methods name
setV (set & validate) which return a String error message or null if the the data 
is valid.
The string is the second 1/2 of the struts message key. The action appends it's name 
to the front
to get the full key.

   public String setVTotalPriceString(String totalPriceString) {
  if (totalPriceString not numeric..) {
 return "total.price.must.be.currency";
  }
   .
   return null;   //yay it's valid
   }

   public String SetVTotalPrice(Currency totalPrice) {
  if (value <= 0) return "value.must.be.greater.than.zero"
  .
  return null;
   {
public Currency getTotalPrice() {
   return totalPrice;
}
/**
* returns display format version. Note if last setV..String call was passed an invalid
* string that value is returned. 
*/ 
public String getTotalPriceString() {
   return totalPriceString;
}

==

please shout very loud if i'm wrong (or incomprehensible)!
Keith.



--- Jim Tomlinson <[EMAIL PROTECTED]> wrote:
> 
> We've had to deal with an analogous problem, though, which I think is
> applicable in a lot of situations. The form is being used to change values
> in a persistent store, but when first displaying the form we want to display
> those values currently in the store. We've gone the route of having the
> session-scope ActionForm's constructor pull the current values from the
> store (obviously via a business logic class, rather than in the form
> itself). Then when the form is posted, the Action can take the new values
> from the ActionForm and persist them (again using another class). Is this
> what most people do, or is there a better way?
> -- 
> Jim Tomlinson
> 
> > -Original Message-
> > From: Keith Bacon [mailto:[EMAIL PROTECTED]]
> > Sent: Thursday, January 10, 2002 7:11 AM
> > To: Struts Users Mailing List
> > Subject: RE: Populating a Form with values
> > 
> > 
> > I think you've missed the point of form beans.
> > On submission of an html form struts looks at the request 
> > parameters. If it can find a matching
> > set method in the form bean it calls it. ie. the form parms 
> > are copied into the form 

RE: Populating a Form with values

2002-01-10 Thread Keith Bacon

For init population put the data in the form bean passed into your perform method, the 
struts tags
in your form will get the values out of the form automatically for you.

> Am I missing something?
nope - you've got it sussed. Some do it your way which I suspect might be 
theoretically better
design - it makes it easier to split  the Action into 2 if required.
Some (like me) do it with 1 action. I have a hidden field hard coded on the form. If 
this is
received I know the form was submitted.
Hope this helps - Keith.

--- "Witt, Mike (OH35)" <[EMAIL PROTECTED]> wrote:
> I was talking about populating the form with information from the database
> so the user can update the data.  What you are saying is that if you did
> this work upfront and set the parameters with values for the field, it would
> populate the form bean automatically if the names match.
> 
> What I have been doing is to use a form and an action, but two action
> mappings for this type of thing.  The first action mapping has a parameter
> of "initialize" and I go and get the data and put it on the form.  The
> second action mapping has a paramater called "update" and I take the data
> from the form, using the form bean and update the database.  Am I missing
> something?
> 
> Mike
> 
> -Original Message-
> From: Keith Bacon [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, January 10, 2002 10:11 AM
> To: Struts Users Mailing List
> Subject: RE: Populating a Form with values
> 
> 
> I think you've missed the point of form beans.
> On submission of an html form struts looks at the request parameters. If it
> can find a matching
> set method in the form bean it calls it. ie. the form parms are copied into
> the form bean.
> 
> When you forward to a jsp with a form struts calls the get methods of the
> form bean to populate
> the the matching form fields (that have been defined with struts tags).
> 
> You action class can deal with the form variables by calling the same
> get/set methods of the form
> bean. This saves doing qqq = request.getParameter("qqq"); & testing for
> nulls etc.
> 
> That's the whole point of form beans - to manage form fields.
> 
> To get readonly data onto your jsp your action class should place it in the
> request where the jsp
> can get at it easily.
> 
> Keith.
> 
> 
> 
> 
> 
> --- "Witt, Mike (OH35)" <[EMAIL PROTECTED]> wrote:
> > I'm new to struts also, but the way I have been doing it is to set up an
> > action and a form bean in the struts config.  The action code (or some
> other
> > bean that the action code uses) for getting the data from the database and
> > populating the form using something like
> > (MyForm)form.setField(theFieldData);
> > 
> > Hope this helps.
> > 
> > Mike
> > 
> > -Original Message-
> > From: Daniel Jaffa [mailto:[EMAIL PROTECTED]]
> > Sent: Thursday, January 10, 2002 9:25 AM
> > To: [EMAIL PROTECTED]
> > Subject: Populating a Form with values
> > 
> > 
> > I am new to struts so be nice (But i have worked with jsp for 2 years).  I
> 
> > have a form that i need to populate a form with values from the database.
> I
> > 
> > pass the form a data_base id to the form but i now need the form to
> populate
> > 
> > the formbean.  I know how to do this in jsp but i want to do the in the 
> > struts way.
> > 
> > _
> > MSN Photos is the easiest way to share and print your photos: 
> > http://photos.msn.com/support/worldwide.aspx
> > 
> > 
> > --
> > To unsubscribe, e-mail:
> > <mailto:[EMAIL PROTECTED]>
> > For additional commands, e-mail:
> > <mailto:[EMAIL PROTECTED]>
> > 
> > --
> > To unsubscribe, e-mail:
> <mailto:[EMAIL PROTECTED]>
> > For additional commands, e-mail:
> <mailto:[EMAIL PROTECTED]>
> > 
> 
> 
> __
> Do You Yahoo!?
> Send FREE video emails in Yahoo! Mail!
> http://promo.yahoo.com/videomail/
> 
> --
> To unsubscribe, e-mail:
> <mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail:
> <mailto:[EMAIL PROTECTED]>
> 
> --
> To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
> 


__
Do You Yahoo!?
Send FREE video emails in Yahoo! Mail!
http://promo.yahoo.com/videomail/

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>




RE: Populating a Form with values

2002-01-10 Thread Jim Tomlinson


We've had to deal with an analogous problem, though, which I think is
applicable in a lot of situations. The form is being used to change values
in a persistent store, but when first displaying the form we want to display
those values currently in the store. We've gone the route of having the
session-scope ActionForm's constructor pull the current values from the
store (obviously via a business logic class, rather than in the form
itself). Then when the form is posted, the Action can take the new values
from the ActionForm and persist them (again using another class). Is this
what most people do, or is there a better way?
-- 
Jim Tomlinson

> -Original Message-
> From: Keith Bacon [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, January 10, 2002 7:11 AM
> To: Struts Users Mailing List
> Subject: RE: Populating a Form with values
> 
> 
> I think you've missed the point of form beans.
> On submission of an html form struts looks at the request 
> parameters. If it can find a matching
> set method in the form bean it calls it. ie. the form parms 
> are copied into the form bean.
> 
> When you forward to a jsp with a form struts calls the get 
> methods of the form bean to populate
> the the matching form fields (that have been defined with 
> struts tags).
> 
> You action class can deal with the form variables by calling 
> the same get/set methods of the form
> bean. This saves doing qqq = request.getParameter("qqq"); & 
> testing for nulls etc.
> 
> That's the whole point of form beans - to manage form fields.
> 
> To get readonly data onto your jsp your action class should 
> place it in the request where the jsp
> can get at it easily.
> 
> Keith.
> 
> 
> 
> 
> 
> --- "Witt, Mike (OH35)" <[EMAIL PROTECTED]> wrote:
> > I'm new to struts also, but the way I have been doing it is 
> to set up an
> > action and a form bean in the struts config.  The action 
> code (or some other
> > bean that the action code uses) for getting the data from 
> the database and
> > populating the form using something like
> > (MyForm)form.setField(theFieldData);
> > 
> > Hope this helps.
> > 
> > Mike
> > 
> > -Original Message-
> > From: Daniel Jaffa [mailto:[EMAIL PROTECTED]]
> > Sent: Thursday, January 10, 2002 9:25 AM
> > To: [EMAIL PROTECTED]
> > Subject: Populating a Form with values
> > 
> > 
> > I am new to struts so be nice (But i have worked with jsp 
> for 2 years).  I 
> > have a form that i need to populate a form with values from 
> the database.  I
> > 
> > pass the form a data_base id to the form but i now need the 
> form to populate
> > 
> > the formbean.  I know how to do this in jsp but i want to 
> do the in the 
> > struts way.
> > 
> > _
> > MSN Photos is the easiest way to share and print your photos: 
> > http://photos.msn.com/support/worldwide.aspx
> > 
> > 
> > --
> > To unsubscribe, e-mail:
> > <mailto:[EMAIL PROTECTED]>
> > For additional commands, e-mail:
> > <mailto:[EMAIL PROTECTED]>
> > 
> > --
> > To unsubscribe, e-mail:   
<mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail:
<mailto:[EMAIL PROTECTED]>
> 


__
Do You Yahoo!?
Send FREE video emails in Yahoo! Mail!
http://promo.yahoo.com/videomail/

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>




RE: Populating a Form with values

2002-01-10 Thread Daniel Jaffa

Thank you very much.  I agree with you that i am still in the learning mode 
and have a far way to go.

But i am also using Vignette so i can not start with the action i have to 
start with the jsp



_
Chat with friends online, try MSN Messenger: http://messenger.msn.com


--
To unsubscribe, e-mail:   
For additional commands, e-mail: 




RE: Populating a Form with values

2002-01-10 Thread Keith Bacon

Most people say best practice is to always start your jsp from the struts action. 
(always use the
/myAction.do not /myAction.jsp).

I think you need to do a lot of studying & messing around to get the hang of struts, 
it's not
totally simple - but web apps never were.
Try http://husted.com/struts/resources.htm

Keith.
--- Daniel Jaffa <[EMAIL PROTECTED]> wrote:
> So i should call my action bean to pre-populate the jsp form?
> 
> Original Message Follows
> From: Keith Bacon <[EMAIL PROTECTED]>
> 
> I think you've missed the point of form beans.
> On submission of an html form struts looks at the request parameters. If it 
> can find a matching
> set method in the form bean it calls it. ie. the form parms are copied into 
> the form bean.
> 
> When you forward to a jsp with a form struts calls the get methods of the 
> form bean to populate
> the the matching form fields (that have been defined with struts tags).
> 
> You action class can deal with the form variables by calling the same 
> get/set methods of the form
> bean. This saves doing qqq = request.getParameter("qqq"); & testing for 
> nulls etc.
> 
> That's the whole point of form beans - to manage form fields.
> 
> To get readonly data onto your jsp your action class should place it in the 
> request where the jsp
> can get at it easily.
> 
> Keith.
> 
> 
> 
> 
> 
> --- "Witt, Mike (OH35)" <[EMAIL PROTECTED]> wrote:
>  > I'm new to struts also, but the way I have been doing it is to set up an
>  > action and a form bean in the struts config.  The action code (or some 
> other
>  > bean that the action code uses) for getting the data from the database 
> and
>  > populating the form using something like
>  > (MyForm)form.setField(theFieldData);
>  >
>  > Hope this helps.
>  >
>  > Mike
>  >
>  > -Original Message-
>  > From: Daniel Jaffa [mailto:[EMAIL PROTECTED]]
>  > Sent: Thursday, January 10, 2002 9:25 AM
>  > To: [EMAIL PROTECTED]
>  > Subject: Populating a Form with values
>  >
>  >
>  > I am new to struts so be nice (But i have worked with jsp for 2 years).  
> I
>  > have a form that i need to populate a form with values from the database. 
>   I
>  >
>  > pass the form a data_base id to the form but i now need the form to 
> populate
>  >
>  > the formbean.  I know how to do this in jsp but i want to do the in the
>  > struts way.
>  >
>  > _
>  > MSN Photos is the easiest way to share and print your photos:
>  > http://photos.msn.com/support/worldwide.aspx
>  >
>  >
>  > --
>  > To unsubscribe, e-mail:
>  > 
>  > For additional commands, e-mail:
>  > 
>  >
>  > --
>  > To unsubscribe, e-mail:   
> 
>  > For additional commands, e-mail: 
> 
>  >
> 
> 
> __
> Do You Yahoo!?
> Send FREE video emails in Yahoo! Mail!
> http://promo.yahoo.com/videomail/
> 
> --
> To unsubscribe, e-mail:   
> 
> For additional commands, e-mail: 
> 
> 
> 
> 
> _
> Send and receive Hotmail on your mobile device: http://mobile.msn.com
> 
> 
> --
> To unsubscribe, e-mail:   
> For additional commands, e-mail: 
> 


__
Do You Yahoo!?
Send FREE video emails in Yahoo! Mail!
http://promo.yahoo.com/videomail/

--
To unsubscribe, e-mail:   
For additional commands, e-mail: 




RE: Populating a Form with values

2002-01-10 Thread Witt, Mike (OH35)

I was talking about populating the form with information from the database
so the user can update the data.  What you are saying is that if you did
this work upfront and set the parameters with values for the field, it would
populate the form bean automatically if the names match.

What I have been doing is to use a form and an action, but two action
mappings for this type of thing.  The first action mapping has a parameter
of "initialize" and I go and get the data and put it on the form.  The
second action mapping has a paramater called "update" and I take the data
from the form, using the form bean and update the database.  Am I missing
something?

Mike

-Original Message-
From: Keith Bacon [mailto:[EMAIL PROTECTED]]
Sent: Thursday, January 10, 2002 10:11 AM
To: Struts Users Mailing List
Subject: RE: Populating a Form with values


I think you've missed the point of form beans.
On submission of an html form struts looks at the request parameters. If it
can find a matching
set method in the form bean it calls it. ie. the form parms are copied into
the form bean.

When you forward to a jsp with a form struts calls the get methods of the
form bean to populate
the the matching form fields (that have been defined with struts tags).

You action class can deal with the form variables by calling the same
get/set methods of the form
bean. This saves doing qqq = request.getParameter("qqq"); & testing for
nulls etc.

That's the whole point of form beans - to manage form fields.

To get readonly data onto your jsp your action class should place it in the
request where the jsp
can get at it easily.

Keith.





--- "Witt, Mike (OH35)" <[EMAIL PROTECTED]> wrote:
> I'm new to struts also, but the way I have been doing it is to set up an
> action and a form bean in the struts config.  The action code (or some
other
> bean that the action code uses) for getting the data from the database and
> populating the form using something like
> (MyForm)form.setField(theFieldData);
> 
> Hope this helps.
> 
> Mike
> 
> -Original Message-
> From: Daniel Jaffa [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, January 10, 2002 9:25 AM
> To: [EMAIL PROTECTED]
> Subject: Populating a Form with values
> 
> 
> I am new to struts so be nice (But i have worked with jsp for 2 years).  I

> have a form that i need to populate a form with values from the database.
I
> 
> pass the form a data_base id to the form but i now need the form to
populate
> 
> the formbean.  I know how to do this in jsp but i want to do the in the 
> struts way.
> 
> _
> MSN Photos is the easiest way to share and print your photos: 
> http://photos.msn.com/support/worldwide.aspx
> 
> 
> --
> To unsubscribe, e-mail:
> <mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail:
> <mailto:[EMAIL PROTECTED]>
> 
> --
> To unsubscribe, e-mail:
<mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail:
<mailto:[EMAIL PROTECTED]>
> 


__
Do You Yahoo!?
Send FREE video emails in Yahoo! Mail!
http://promo.yahoo.com/videomail/

--
To unsubscribe, e-mail:
<mailto:[EMAIL PROTECTED]>
For additional commands, e-mail:
<mailto:[EMAIL PROTECTED]>

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>




RE: Populating a Form with values

2002-01-10 Thread Daniel Jaffa

So i should call my action bean to pre-populate the jsp form?

Original Message Follows
From: Keith Bacon <[EMAIL PROTECTED]>

I think you've missed the point of form beans.
On submission of an html form struts looks at the request parameters. If it 
can find a matching
set method in the form bean it calls it. ie. the form parms are copied into 
the form bean.

When you forward to a jsp with a form struts calls the get methods of the 
form bean to populate
the the matching form fields (that have been defined with struts tags).

You action class can deal with the form variables by calling the same 
get/set methods of the form
bean. This saves doing qqq = request.getParameter("qqq"); & testing for 
nulls etc.

That's the whole point of form beans - to manage form fields.

To get readonly data onto your jsp your action class should place it in the 
request where the jsp
can get at it easily.

Keith.





--- "Witt, Mike (OH35)" <[EMAIL PROTECTED]> wrote:
 > I'm new to struts also, but the way I have been doing it is to set up an
 > action and a form bean in the struts config.  The action code (or some 
other
 > bean that the action code uses) for getting the data from the database 
and
 > populating the form using something like
 > (MyForm)form.setField(theFieldData);
 >
 > Hope this helps.
 >
 > Mike
 >
 > -Original Message-
 > From: Daniel Jaffa [mailto:[EMAIL PROTECTED]]
 > Sent: Thursday, January 10, 2002 9:25 AM
 > To: [EMAIL PROTECTED]
 > Subject: Populating a Form with values
 >
 >
 > I am new to struts so be nice (But i have worked with jsp for 2 years).  
I
 > have a form that i need to populate a form with values from the database. 
  I
 >
 > pass the form a data_base id to the form but i now need the form to 
populate
 >
 > the formbean.  I know how to do this in jsp but i want to do the in the
 > struts way.
 >
 > _
 > MSN Photos is the easiest way to share and print your photos:
 > http://photos.msn.com/support/worldwide.aspx
 >
 >
 > --
 > To unsubscribe, e-mail:
 > 
 > For additional commands, e-mail:
 > 
 >
 > --
 > To unsubscribe, e-mail:   

 > For additional commands, e-mail: 

 >


__
Do You Yahoo!?
Send FREE video emails in Yahoo! Mail!
http://promo.yahoo.com/videomail/

--
To unsubscribe, e-mail:   

For additional commands, e-mail: 




_
Send and receive Hotmail on your mobile device: http://mobile.msn.com


--
To unsubscribe, e-mail:   
For additional commands, e-mail: 




RE: Populating a Form with values

2002-01-10 Thread Keith Bacon

I think you've missed the point of form beans.
On submission of an html form struts looks at the request parameters. If it can find a 
matching
set method in the form bean it calls it. ie. the form parms are copied into the form 
bean.

When you forward to a jsp with a form struts calls the get methods of the form bean to 
populate
the the matching form fields (that have been defined with struts tags).

You action class can deal with the form variables by calling the same get/set methods 
of the form
bean. This saves doing qqq = request.getParameter("qqq"); & testing for nulls etc.

That's the whole point of form beans - to manage form fields.

To get readonly data onto your jsp your action class should place it in the request 
where the jsp
can get at it easily.

Keith.





--- "Witt, Mike (OH35)" <[EMAIL PROTECTED]> wrote:
> I'm new to struts also, but the way I have been doing it is to set up an
> action and a form bean in the struts config.  The action code (or some other
> bean that the action code uses) for getting the data from the database and
> populating the form using something like
> (MyForm)form.setField(theFieldData);
> 
> Hope this helps.
> 
> Mike
> 
> -Original Message-
> From: Daniel Jaffa [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, January 10, 2002 9:25 AM
> To: [EMAIL PROTECTED]
> Subject: Populating a Form with values
> 
> 
> I am new to struts so be nice (But i have worked with jsp for 2 years).  I 
> have a form that i need to populate a form with values from the database.  I
> 
> pass the form a data_base id to the form but i now need the form to populate
> 
> the formbean.  I know how to do this in jsp but i want to do the in the 
> struts way.
> 
> _
> MSN Photos is the easiest way to share and print your photos: 
> http://photos.msn.com/support/worldwide.aspx
> 
> 
> --
> To unsubscribe, e-mail:
> 
> For additional commands, e-mail:
> 
> 
> --
> To unsubscribe, e-mail:   
> For additional commands, e-mail: 
> 


__
Do You Yahoo!?
Send FREE video emails in Yahoo! Mail!
http://promo.yahoo.com/videomail/

--
To unsubscribe, e-mail:   
For additional commands, e-mail: 




RE: Populating a Form with values

2002-01-10 Thread Witt, Mike (OH35)

I'm new to struts also, but the way I have been doing it is to set up an
action and a form bean in the struts config.  The action code (or some other
bean that the action code uses) for getting the data from the database and
populating the form using something like
(MyForm)form.setField(theFieldData);

Hope this helps.

Mike

-Original Message-
From: Daniel Jaffa [mailto:[EMAIL PROTECTED]]
Sent: Thursday, January 10, 2002 9:25 AM
To: [EMAIL PROTECTED]
Subject: Populating a Form with values


I am new to struts so be nice (But i have worked with jsp for 2 years).  I 
have a form that i need to populate a form with values from the database.  I

pass the form a data_base id to the form but i now need the form to populate

the formbean.  I know how to do this in jsp but i want to do the in the 
struts way.

_
MSN Photos is the easiest way to share and print your photos: 
http://photos.msn.com/support/worldwide.aspx


--
To unsubscribe, e-mail:

For additional commands, e-mail:


--
To unsubscribe, e-mail:   
For additional commands, e-mail: