RE: How to get data back from ActionForm to HTML form

2002-10-09 Thread Rohra, Prakash N. ,,DMDC/BEAU


Ok..I figured it out...

For "html:text" tag,  there is an attribute named "name" which means
following:
"The attribute name of the bean whose properties are consulted when
rendering the current value of this input field. If not specified, the bean
associated with the form tag we are nested within is utilized. [RT Expr]"

So I had 2 ways to fix it:
(1) Use html:text property="rank" name="personnelForm"  
This would explicitly copy the values from "personnelForm" to my
HTML form for given text field.

(2) In my personnel.jsp's  tag, whatever "Submit" action I am using, I
associate "personnelForm" with that Action.
This would copy the values from "personnelForm" for all matching
text fields on my form without specifying name="" for each text field.

thanks



-Original Message-
From: Wendy Smoak [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, October 09, 2002 1:48 PM
To: 'Struts Users Mailing List'
Subject: RE: How to get data back from ActionForm to HTML form


> When I access "/getpersonnel.do" action,
> I expect that after my PersonnelAction.execute() function returns and
> personnel.jsp is executed, I would see HTML text
> controls filled with "RANK" and "PG" values. But they appear blank.
> What am I missing here..??

It looks pretty similar to struts-example.  You have some
System.out.println's right after the PropertyUtils call should have filled
in the properties.  What do they print out?

Right now, I'd suspect that the property names don't match exactly and
PropertyUtils isn't actually copying the values over.  (But that's only
because I can't see that code to check for myself.)  If that's not it, I'd
go back to struts-example and change it into what you want, so you know
you're starting with something that works.

I'm sure it's going to be something simple, but I don't see anything wrong.

-- 
Wendy Smoak
http://sourceforge.net/projects/unidbtags 


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




RE: How to get data back from ActionForm to HTML form

2002-10-09 Thread Wendy Smoak

> When I access "/getpersonnel.do" action,
> I expect that after my PersonnelAction.execute() function returns and
> personnel.jsp is executed, I would see HTML text
> controls filled with "RANK" and "PG" values. But they appear blank.
> What am I missing here..??

It looks pretty similar to struts-example.  You have some
System.out.println's right after the PropertyUtils call should have filled
in the properties.  What do they print out?

Right now, I'd suspect that the property names don't match exactly and
PropertyUtils isn't actually copying the values over.  (But that's only
because I can't see that code to check for myself.)  If that's not it, I'd
go back to struts-example and change it into what you want, so you know
you're starting with something that works.

I'm sure it's going to be something simple, but I don't see anything wrong.

-- 
Wendy Smoak
http://sourceforge.net/projects/unidbtags 




RE: How to get data back from ActionForm to HTML form

2002-10-09 Thread Rohra, Prakash N. ,,DMDC/BEAU

Hmmm I looked in the example application (editResgistration). I have
similar code, but still doesn't work for me.

Here is snippets of my code:
In struts-config.xml







In PersonnelAction.java
=
public ActionForward execute(ActionMapping mapping,
 ActionForm form,
 HttpServletRequest request,
 HttpServletResponse response)
throws Exception 
  {

// Extract attributes we will need
Locale locale = getLocale(request);
MessageResources messages = getResources(request);
HttpSession session = request.getSession();

  System.out.println("I am in Personnel Action");
  PersonnelForm fForm = (PersonnelForm)form;

  PersonnelVO personnelVO = new PersonnelVO();  // has 'rank' and
'paygrade' properties
   
  personnelVO.setRank("RANK");
  personnelVO.setPaygrade("PG");  

  PropertyUtils.copyProperties(fForm, personnelVO);  
  System.out.println(fForm.getRank());
  System.out.println(fForm.getPaygrade());  

 
  // Forward control to the specified success URI
return (mapping.findForward("success"));

}

And finally here is personnel.jsp
=

<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>















  

  


  

  

  

  


  

  

  

  


  

  








=
When I access "/getpersonnel.do" action,
I expect that after my PersonnelAction.execute() function returns and
personnel.jsp is executed, I would see HTML text
controls filled with "RANK" and "PG" values. But they appear blank.

What am I missing here..??

thanks for all the help..



-Original Message-----
From: Wendy Smoak [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, October 08, 2002 6:12 PM
To: 'Struts Users Mailing List'
Subject: RE: How to get data back from ActionForm to HTML form


> I tried it, and I still don't see Text fields populated in HTML form..
> Does this mean I will have to manually write code to get handle to fForm
> from 'request' and call fForm.getXXX() in my JSP file ??
> I thought html:text property="XXX" should automatically get the matching
> property value from the ActionForm in the similar way it does while
POSTing.
> I must be missing something here...

I had the opposite problem... things were magically appearing in the HTML
form and I couldn't see how.  I had started with the example app, and I
finally found the line, which I commented appropriately:

/*
 *  Magic!  This populates all of the ContactForm
 *  properties with the matching ones in the Contact
 */
PropertyUtils.copyProperties( contactform, contact );

'contact' is my Value Object, and 'contactform' is the [extension of]
ActionForm. 

HTH!  Take a look at struts-example to see how it works.

-- 
Wendy Smoak
http://sourceforge.net/projects/unidbtags 

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




RE: How to get data back from ActionForm to HTML form

2002-10-08 Thread Wendy Smoak

> I tried it, and I still don't see Text fields populated in HTML form..
> Does this mean I will have to manually write code to get handle to fForm
> from 'request' and call fForm.getXXX() in my JSP file ??
> I thought html:text property="XXX" should automatically get the matching
> property value from the ActionForm in the similar way it does while
POSTing.
> I must be missing something here...

I had the opposite problem... things were magically appearing in the HTML
form and I couldn't see how.  I had started with the example app, and I
finally found the line, which I commented appropriately:

/*
 *  Magic!  This populates all of the ContactForm
 *  properties with the matching ones in the Contact
 */
PropertyUtils.copyProperties( contactform, contact );

'contact' is my Value Object, and 'contactform' is the [extension of]
ActionForm. 

HTH!  Take a look at struts-example to see how it works.

-- 
Wendy Smoak
http://sourceforge.net/projects/unidbtags 



RE: How to get data back from ActionForm to HTML form

2002-10-08 Thread Rohra, Prakash N. ,,DMDC/BEAU

I tried it, and I still don't see Text fields populated in HTML form..

Does this mean I will have to manually write code to get handle to fForm
from 'request' and call fForm.getXXX() in my JSP file ??

I thought html:text property="XXX" should automatically get the matching
property value from the ActionForm in the similar way it does while POSTing.

I must be missing something here...



-Original Message-
From: William Wan [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, October 08, 2002 3:18 PM
To: 'Struts Users Mailing List'
Subject: RE: How to get data back from ActionForm to HTML form


You have to add 
request.setAttribute("personnelForm ", fForm);
in the action so that the form will be stored in the request for
population in jsp. Otherwsie the tForm will only be available within
your action scope only.

-Original Message-
From: Rohra, Prakash N. ,,DMDC/BEAU [mailto:[EMAIL PROTECTED]] 
Sent: Wednesday, October 09, 2002 3:02 AM
To: '[EMAIL PROTECTED]'
Subject: How to get data back from ActionForm to HTML form

Hello..

I am a newbie to Struts. While reading the documentation, I gathered
that
"ActionForm" objects can be used to move data back and forth between
HTML
forms fields and ActionForm properties by using the formBeans.

With proper entries in struts-congif.xml, Struts framework automatically
creates the instance of "ActionForm" class and populates its properties
based on the HTTP Post Request parameters while submitting a HTML form.
I
can see the form values in m y ActionForm and also in Action class.

However, how do I achieve the same thing backwards. I mean, if I
retrieve or
generate some values in a Action class code, and populate these values
in
the ActionForm by calling myForm.setXXX(), I don't see these values
appearing in the corresponding HTML form that gets forwarded by my
Action.

here is the part of my struts-config.xml





 


Here is the code from PersonnelAction.java:

public ActionForward execute(ActionMapping mapping,
 ActionForm form,
 HttpServletRequest request,
 HttpServletResponse response)
throws Exception 
{

  PersonnelForm fForm = (PersonnelForm)form;
  fForm.setRank("RANK");
  fForm.setPaygrade("PG");

  System.out.println(fForm.getRank());
  System.out.println(fForm.getPaygrade());

}


Where rank, paygrade are properties of PersonnelForm.java and also
defined
as html:text in personnel.jsp.

When I execute the /getpersonnel.do action, I see my code getting
executed
in PersonnelAction.java, but muy text fields in HTML form generated by
personnel.jsp are blank. I expected it to display the data from
PersonnelForm properties.

What am I doing wrong?

thanks

-Prakash




--
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]>

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




RE: How to get data back from ActionForm to HTML form

2002-10-08 Thread William Wan

You have to add 
request.setAttribute("personnelForm ", fForm);
in the action so that the form will be stored in the request for
population in jsp. Otherwsie the tForm will only be available within
your action scope only.

-Original Message-
From: Rohra, Prakash N. ,,DMDC/BEAU [mailto:[EMAIL PROTECTED]] 
Sent: Wednesday, October 09, 2002 3:02 AM
To: '[EMAIL PROTECTED]'
Subject: How to get data back from ActionForm to HTML form

Hello..

I am a newbie to Struts. While reading the documentation, I gathered
that
"ActionForm" objects can be used to move data back and forth between
HTML
forms fields and ActionForm properties by using the formBeans.

With proper entries in struts-congif.xml, Struts framework automatically
creates the instance of "ActionForm" class and populates its properties
based on the HTTP Post Request parameters while submitting a HTML form.
I
can see the form values in m y ActionForm and also in Action class.

However, how do I achieve the same thing backwards. I mean, if I
retrieve or
generate some values in a Action class code, and populate these values
in
the ActionForm by calling myForm.setXXX(), I don't see these values
appearing in the corresponding HTML form that gets forwarded by my
Action.

here is the part of my struts-config.xml





 


Here is the code from PersonnelAction.java:

public ActionForward execute(ActionMapping mapping,
 ActionForm form,
 HttpServletRequest request,
 HttpServletResponse response)
throws Exception 
{

  PersonnelForm fForm = (PersonnelForm)form;
  fForm.setRank("RANK");
  fForm.setPaygrade("PG");

  System.out.println(fForm.getRank());
  System.out.println(fForm.getPaygrade());

}


Where rank, paygrade are properties of PersonnelForm.java and also
defined
as html:text in personnel.jsp.

When I execute the /getpersonnel.do action, I see my code getting
executed
in PersonnelAction.java, but muy text fields in HTML form generated by
personnel.jsp are blank. I expected it to display the data from
PersonnelForm properties.

What am I doing wrong?

thanks

-Prakash




--
To unsubscribe, e-mail:

For additional commands, e-mail:





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