RE: Can V in MVC be Swing in Struts?

2002-10-18 Thread Rohra, Prakash N. ,,DMDC/BEAU
Ok..Peace guys...

I got my answers... and more.. :-)

Thanks Craig..



-Original Message-
From: Xue-Feng Yang [mailto:just4look;yahoo.com]
Sent: Thursday, October 17, 2002 1:20 PM
To: Struts Users Mailing List
Subject: RE: Can V in MVC be Swing in Struts?


Let me copy your answer here with #, and tell me where
is your correct answer.

 And you didn't understand the answer correctly :-).


# There are at least two different ways to accomplish
# this:
 
#* Have your Action write the XML output directly to
#the response,
#  and then return null (indicates that the response
#has been completed,
#  so no forwarding is necessary).

#* Have the JSP pages you forward to (for the view)
#render text/xml
#  instead of text/html.  You won't be using the
# struts-html tags
#  in this scenario, but you'll be able to fill in
#dynamic parts of
#  the response with things like bean:write or
#bean:message:

#  customer
#...
#namebean:write name=customer
#property=name//name
#...
#  /customer

#In some scenarios, you will also want to transform
#the XML output
#depending on what the user agent is, or for other
#similar reasons.  Check
#out the STXX framework (search in Google to find
#it), which layers on top
#of Struts and lets you specify a pipeline of XSLT
#transformations to be
#performed on the response that your app itself
#generates. 






 --- Craig R. McClanahan [EMAIL PROTECTED]
wrote:  
 
 On Thu, 17 Oct 2002, Xue-Feng Yang wrote:
 
  You didn't read the question correctly. The
 question
  is:
 
  Does STRUTS support sending serialized VO objects
 (as
  against HTML or XML text strings) back and forth
  between client app and server.
 
 
 And you didn't understand the answer correctly :-).
 
 Struts (the framework) makes ***zero*** requirements
 on what the output
 looks like -- that is up to your application to
 decide.  You can even
 generate binary output if you like (such as a
 dynamically generated graph,
 or serialized value objects)  by writing directly to
 the
 ServletOutputStream and then returning null from
 your action.
 
 Struts (the struts-html tag library) does render
 HTML output, but you
 won't want to use this if you are writing non-HTML
 stuff.
 
 Craig
 
 
 --
 To unsubscribe, e-mail:  
 mailto:struts-user-unsubscribe;jakarta.apache.org
 For additional commands, e-mail:
 mailto:struts-user-help;jakarta.apache.org
  

__ 
Post your free ad now! http://personals.yahoo.ca

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

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




RE: Can V in MVC be Swing in Struts?

2002-10-18 Thread Rohra, Prakash N. ,,DMDC/BEAU
OK.I asked the original question...
Did I get the answer exactly in the way/format I was looking for ?? Probably
not..

Yes...Craig didn't mention the words Serialized and VO in the original
answer.

But hey...the answer was more than adequate to satisify my original query
and apply the same concept for serialized objects.

Thanks

-Original Message-
From: Xue-Feng Yang [mailto:just4look;yahoo.com]
Sent: Thursday, October 17, 2002 2:04 PM
To: Struts Users Mailing List
Subject: RE: Can V in MVC be Swing in Struts?


1) it is not my question;

2) I just pointed out that Craig didn't answer the
question:

  (1) Does STRUTS support sending serialized VO
 objects (as against HTML or  XML text strings) back
 and forth between client
 app and server. What needs to be changed in STRUTS
 components to suport this?

3) As a open source forum, any one should not mis-lead
the people who asked the questions here.

 



--- Kevin A. Smith [EMAIL PROTECTED] wrote:
 What do you hope to accomplish by badgering people?
 It seems to me that Craig answered your question in
 more than adequate detail.
 
 --Kevin
 
 -Original Message-
 From: Xue-Feng Yang [mailto:just4look;yahoo.com]
 Sent: Thursday, October 17, 2002 1:52 PM
 To: Struts Users Mailing List
 Subject: Re: Can V in MVC be Swing in Struts?
 
 
  --- Antoni Reus [EMAIL PROTECTED] wrote: 
 Hi,
  
  A Dijous 17 Octubre 2002 19:31, Xue-Feng Yang va
  escriure:
--- Craig R. McClanahan [EMAIL PROTECTED]
   wrote: 
  
On Thu, 17 Oct 2002, Xue-Feng Yang wrote:
 Date: Thu, 17 Oct 2002 13:19:48 -0400 (EDT)
 From: Xue-Feng Yang [EMAIL PROTECTED]
 Reply-To: Struts Users Mailing List
   
[EMAIL PROTECTED]
   
 To: Struts Users Mailing List
   
[EMAIL PROTECTED]
   
 Subject: RE: Can V in MVC be Swing in
 Struts?

 Let me copy your answer here with #, and
 tell
  me
   
where
   
 is your correct answer.

  And you didn't understand the answer
  correctly
:
:-).
:
 # There are at least two different ways to
   
accomplish
   
 # this:

 #* Have your Action write the XML output
  directly
   
to
   
 #the response,
 #  and then return null (indicates that the
   
response
   
 #has been completed,
 #  so no forwarding is necessary).
   
To use output directly generated by an Action
(either serialized objects,
or directly created XML), use this.
  
   Hahaha, where is the VO in your message with #?
  You
   only talked about XML not VO.
  
  
  
  html, xml, serialized objects, pdf, svg,  what's
 the
  difference?
  
  For serialized objects:
  
  Set the content type to
  application/x-java-serialized-object
  Grab the ServletOuputStream in a
 ObjectOutputStream
  and write(Object it)
  return null 
  
  
  Salut,
  
  -- Antoni Reus
 
 
 You should answer this question. It is correct now.
 Just remind you that it is not my question.
 
 A person asked the following question:
 
  (1) Does STRUTS support sending serialized VO
 objects (as against HTML or  XML text strings) back
 and forth between client
 app and server. What needs to be changed in STRUTS
 components to suport this?
 
 And I just point out someone's answer is not a
 correct
 answer. That's it.
 
  
  
  --
  To unsubscribe, e-mail:  
 
 mailto:struts-user-unsubscribe;jakarta.apache.org
  For additional commands, e-mail:
  mailto:struts-user-help;jakarta.apache.org
   
 

__
 
 Post your free ad now! http://personals.yahoo.ca
 
 --
 To unsubscribe, e-mail:  
 mailto:struts-user-unsubscribe;jakarta.apache.org
 For additional commands, e-mail:
 mailto:struts-user-help;jakarta.apache.org
 
 
 --
 To unsubscribe, e-mail:  
 mailto:struts-user-unsubscribe;jakarta.apache.org
 For additional commands, e-mail:
 mailto:struts-user-help;jakarta.apache.org
 


__ 
Post your free ad now! http://personals.yahoo.ca

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

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




Why Use Serialized Value Objects instead of XML or SOAP? (Was.... Can V in MVC be Swing in Struts?)

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

Your observations are perfectly valid and to-the-point.
We are trying to answer some of the same questions you have raised.

Just to give you a little background : The application involves hundreds of
Busines Objects and complex business rules.
The number of different ways in which a client can manipulate Business
objects (POST methods or RPC calls) is quite large (ofcourse we are planning
to use Facades and BusinessDelegates to avoid too many granular actions).

Our first stab at the design was to model all Business objects as Java
Classes (We have good reasons not to use EJBs, but that is a different
story). For some reasons, the front-end has to be a java swing application. 
We will have ValueObjects that will be passed back and forth between server
and client.

The transfer of value objects data between client tier and web/app tier
could be (1) XML (2) Serialized objects.
Sending XML representation of ValueObjects would increase our 'payload' by
factor of atleast 5 (due to XML tags etc.) and also we have to write
conversion routines. Our ValueObjects hierarchy is a bit complex. (JAXB
could help here though.)
On the other hand sending Serialized Value Objects tree seems straight
forward and efficient. So we decided to give it a shot. Don't know if that
is the best way.

Regarding using the SOAP, we are seriously looking at it as an option.
(Trying to get upto speed on web services is the first step...I guess :-))

I would value your take on this...please provide your opinion...

thanks



-Original Message-
From: [EMAIL PROTECTED] [mailto:Kevin.Bedell;sunlife.com]
Sent: Thursday, October 17, 2002 2:28 PM
To: Struts Users Mailing List
Subject: RE: Can V in MVC be Swing in Struts?






At the risk of me seeming simple and pointless, can I ask why you want
manually code sending serialized objects over HTTP?

What you're doing is reinventing SOAP and XML-RPC. These technologies are
not that hard to use - especially XML-RPC. There are Java libraries
available that handle all the communications for you and just hand your
code XML docs.

Not to mention debugging the application is much easier if you are using
XML because at least it's readable english -

You may also run the risk that you'll code a whole bunch of stuff this way
and then later you'll be asked to refactor them as web services. 'Which is
probably what you should've done to begin with', is what they'll say.

Of course, I could be way off base. From my viewpoint I don't know what
your requirements are -

Kevin



---
This e-mail message (including attachments, if any) is intended for the use
of the individual or entity to which it is addressed and may contain
information that is privileged, proprietary , confidential and exempt from
disclosure.  If you are not the intended recipient, you are notified that
any dissemination, distribution or copying of this communication is
strictly prohibited.  If you have received this communication in error,
please notify the sender and erase this e-mail message immediately.
---



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

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




RE: Can V in MVC be Swing in Struts?

2002-10-18 Thread Rohra, Prakash N. ,,DMDC/BEAU
We have a similar situation where Server side Struts components (Actions and
JavaBean business components) will be accessed by a client Swing Java
application (not a browser).

We are also looking at various alternatives like SOAP, XML-RPC or simple
HTTP POST requests (with XML data or Serialized objects).

I have 2 questions:

(1) Does STRUTS support sending serialized VO objects (as against HTML or
XML text strings) back and forth between client app and server. What needs
to be changed in STRUTS components to suport this?

(2) Does SOAP (Web services) support client sessions ? i.e. will I be able
to maintain individual client's session state (which might be full business
object JavaBeans) or Web services are suited for state-less method calls??
Any pointers will be appriciated ??

thanks


-Original Message-
From: [EMAIL PROTECTED] [mailto:Kevin.Bedell;sunlife.com]
Sent: Thursday, October 17, 2002 10:56 AM
To: Struts Users Mailing List
Subject: Re: Can V in MVC be Swing in Struts?





Using Struts/Soap/EJB for XML?

Using SOAP implies (usually) communications between the client app and the
server over HTTP. Using EJB generally implies communications from the
client and server using RMI.

The only way I can see to do what you are describing is to 'wrap' an EJB on
the server using a Web Service. Which, btw, is exactly what Weblogic and
JBoss.NET do for web services. But these are not the only solutions.

If you are interested in using SOAP for communications between the client
and server, then Apache AXIS is likely your best bet. It provides about the
best and most current Java SOAP client code. (More up to date then Apache
SOAP.) You could then code your back-end processing in Java (if you want -
and which is my personal choice!) using Axis as well. The Java2WSDL and
WSDL2Java utilities provided by Axis are a good place to start.

My upcoming book, Struts Kick Start, has a chapter and a sample application
dedicated to exactly this solution. It provides a Struts App that uses SOAP
and XML to communicate to a Java-based Web Service that was built using
Axis. I include build files and scripts to generate the .java files using
the Java2WSDL and WSDL2Java utilities. Also, copies of Axis (and struts,
etc) are included on the CD-ROM that comes with the book.

Regarding Code Generators - XDoclet seems the best for this work, but it is
still a bit immature when it comes to the web service stuff - Struts code
generation is provided, though I've not used it. There is an Ant task under
development that automatically generates Java code for web service
communications (it wraps the Java2WSDL and WSDL2Java utilities) but it is
not ready for prime time yet and no documentation yet exists.

Best of luck,

Kevin


--
Kevin Bedell
Author, Struts Kick Start










Xue-Feng Yang [EMAIL PROTECTED] on 10/17/2002 10:27:29 AM

Please respond to Struts Users Mailing List
   [EMAIL PROTECTED]

To:Struts Users Mailing List [EMAIL PROTECTED]
cc: (bcc: Kevin Bedell/Systems/USHO/SunLife)
Subject:Re: Can V in MVC be Swing in Struts?


Thanks for the suggestions.

The architecture of my project is different from
standard B2B and B2C although they are part of it.

I will choose Struts/Soap/EJB to deal with XML, but
implement other parts from ground to Struts.

I would like to know if there are good code generators
for XML/Struts/Soap/EJB. Seems to me this part of the
code is standard now.


--- [EMAIL PROTECTED] wrote:



 If you decline to use SOAP protocol and want to
 build an interface that
 returns XML over HTTP, I'd recommend looking XML-RPC
 protocol - it's
 simpler and actually pretty easy to use. The
 O'Reilly XML-RPC book gives
 you step by step instructions on how to do it and
 even points you to Java
 libraries that can save you a bunch of time.

 The value here is that there are Java libraries
 available for you to use to
 manage all the communications from the client. You
 wouldn't have to write
 any low-level communications stuff, you could just
 use the packages already
 available - plus there are VB, Perl, Python, etc
 packages available for
 XML-RPC clients as well so it would make your
 service much more reusable.






 Vilya Harvey [EMAIL PROTECTED] on
 10/17/2002 05:13:33 AM

 Please respond to Struts Users Mailing List
[EMAIL PROTECTED]

 To:Struts Users Mailing List
 [EMAIL PROTECTED]
 cc: (bcc: Kevin Bedell/Systems/USHO/SunLife)
 Subject:Re: Can V in MVC be Swing in Struts?


 You're right, it will work. In a previous job, I
 worked on a project which
 had a Visual Basic (!) client talking to some EJBs
 via servlets which
 returned XML responses. That project wasn't using
 JSP, simply because
 servlets were more convenient in that case, but
 there's no reason why it
 couldn't have. We found a lot of benefits from this
 approach.

 The downside was that a fair amount of time was
 spent defining the exact
 protocol between the client and the servlets. Of
 course, this 

RE: Why Use Serialized Value Objects instead of XML or SOAP? (Was.... Can V in MVC be Swing in Struts?)

2002-10-18 Thread Rohra, Prakash N. ,,DMDC/BEAU
Kevin,
Thanks for showing interest in these issues...I appreciate...we hope to
answer some of the questions we have been debating. Please see comments
below:



 Just to give you a little background : The application involves hundreds
of
 Busines Objects and complex business rules.
 The number of different ways in which a client can manipulate Business
 objects (POST methods or RPC calls) is quite large (ofcourse we are
planning
 to use Facades and BusinessDelegates to avoid too many granular actions).

Couple questions/assumptions:

 - Am I right in assuming that a good number of these business objects need
to be accessible to the Client application individually even counting the
facades you create? Sounds like you could have 100 or more 'endpoints'.

 - And these individual 'endpoints' need to be accessible from the Swing
application?

 Probably Yes..Hiding all the business objects behind the facaded and
delegates may turn out to be tough.

 - If so, then the creation of each individual endpoint needs to be pretty
efficient. That is, it can't take hours of coding time to add a new
endpoint.

(I'm using the term 'endpoint' as it is a part of the WSDL spec with a
particular meaning).

 We have been considering using reflection to make method calls on
individual business objects from a common facade based on the method
Name and Parameter List passed. Might work for simple methods calls and
primitive parameter types, but could be a problem for more complex
types...still not sure how we will solve the objectID (object reference)
problem. 



 - Another question is how reliable is the application? If you ABSOLUTELY
CANNOT lose a message, then HTTP in general may be a problem. It's not
designed to provide a guarantee of 'once and only once' delivery. That
being said, many times the loss of a request isn't as big a deal as it
first seems. The Swing application can sense a problem and just retry. The
real problem could occur if the message is delivered, but the response to
the swing application isn't conclusive so it resends.

 YepBut I think this may not be a big issue in our application.
Resending the same command
may be fine. 

 - Another question is are you tied to HTTP? If you are on an intranet and
can use some other transport you may be able to get better reliability (and
potentially performance). More on this below.

 The application will be available mostly on the internet so I guess we
need HTTP.


 Our first stab at the design was to model all Business objects as Java
 Classes (We have good reasons not to use EJBs, but that is a different
 story). For some reasons, the front-end has to be a java swing
application.
 We will have ValueObjects that will be passed back and forth between
server
 and client.

Non-EJB's are fine - though they have advantages if you need to manage
transactions and roll-back things that fail mid-stream.

Sending Value Objects seems a good decsion - they aren't tied to any
particular app on either the front or back and they are easy to model in
XML if desired.


 The transfer of value objects data between client tier and web/app tier
 could be (1) XML (2) Serialized objects.
 Sending XML representation of ValueObjects would increase our 'payload'
by
 factor of atleast 5 (due to XML tags etc.) and also we have to write
 conversion routines. Our ValueObjects hierarchy is a bit complex. (JAXB
 could help here though.)
 On the other hand sending Serialized Value Objects tree seems straight
 forward and efficient. So we decided to give it a shot. Don't know if
that
 is the best way.

A third option you haven't mentioned is using JMS (assuming you want to
stay J2EE-based). JMS provides higher reliability than anything you would
send over HTTP.  Since JMS is transactional it can guarantee 'once and only
once' delivery. Plus it works great for carrying objects in general. It
also provides you a way to persist requests if the back-end goes down in
the middle of something.

But JMS messages would need to be 'pulled' by the server. What you may need
to do would be have the client send a JMS message into a queue, then have
another app that locks on the queue waiting for a message. This app would
receive the message, invoke a request to Struts (assuming you need to use
struts on the server) and then get the response and package it back up to
return on the queue. Things would honestly be easier if you just had your
server application locking on the queue directly and you didn't use Struts
(of course, then you wouldn't be here!).

 Didn't even think about using JMS.!! Will look in the possibility of
using JMS.. thanks

Another option would be to have the Swing app use Axis/SOAP, but sending
the SOAP messages over JMS instead of HTTP. Interestingly, I just posted a
weblog entry on this approach on O'Reilly's oreillynet.com site a couple
days ago (See SOAP over JMS - What does it mean and why should I care?
http://www.oreillynet.com/pub/wlg/2171 ). The advantage of this is that you
use Web 

RE: Struts forms best practice

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

Craig and other gurus,

Any thoughts on how to re-use the ValueObjects across web/app tiers.

Most of the time people end up defining the data attributes in actual
business objects (where the business logic resides) and also deplicating the
same 'data attributes' in Value objects. The value objects are then passed
back and forth between web and app tier. (And then, there are Form beans
also which need the same data members.)

Would it make sense to have data attributes defined only in Value Onjects
and let the actual BusinessObjects (containing the business logic) and Form
Beans have reference to these Value objects.

So for e.g. a Person business object points to PersonVO 
and PesonForm points to PersonVO.

Any thoughts??

thanks


-Original Message-
From: Craig R. McClanahan [mailto:[EMAIL PROTECTED]]
Sent: Friday, October 11, 2002 2:27 PM
To: Struts Users Mailing List
Subject: RE: Struts forms best practice




On Fri, 11 Oct 2002, Andy Kriger wrote:

 Date: Fri, 11 Oct 2002 13:06:30 -0400
 From: Andy Kriger [EMAIL PROTECTED]
 Reply-To: Struts Users Mailing List [EMAIL PROTECTED]
 To: Struts Users Mailing List [EMAIL PROTECTED]
 Subject: RE: Struts forms best practice

 Does this mean that you will have an ActionForm with String fields and a
 ModelBean that basically has all the same fields but with the correct
types?
 And that ModelBean is passed around the struts framework?


The model beans are passed around the back end, and sometimes exposed as
request attributes for read-only access from the presentation layer.

 If so, how do folks reduce code duplication between the utility ActionForm
 and the data modelling ModelBean?

Use DynaActionForm or DynaValidatorForm form beans so you don't actually
have to write form bean classes (except perhaps for custom reset() and/or
validate() methods).  [Requires 1.1]

Make the developers providing your persistence tier logic provide you the
value objects (after all, they should be reusable in non-web-based apps as
well) so that you don't have to do all the work :-).

Use tools to generate form bean and/or value object classes from some
common description of the properties.  I understand XDoclet can be used
for things like this; I'm sure there are others as well.  If you adopt a
strategy of maintaining the data definitions and always generating the
classes you need, code duplication is a non-issue.


 -a

Craig


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


form-bean  name=personnelForm
type=blankApp.PersonnelForm/

actionpath=/getpersonnel
   type=blankApp.PersonnelAction
   name=personnelForm
  scope=request
  validate=false


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 %

html:html locale=true
head
titlebean:message key=index.title//title
html:base/
/head
body bgcolor=white

html:errors/

html:form action=/updaterank focus=rank
table border=0 width=100%


h3centerbean:message key=index.message.getrank//center/h3
  tr
th align=right
  bean:message key=prompt.rank/
/th
td align=left
  html:text property=rank  size=16 maxlength=16/
/td
  /tr

  tr
th align=right
  bean:message key=prompt.paygrade/
/th
td align=left
  html:text property=paygrade size=16 maxlength=16/
/td
  /tr

  tr
td align=right
  html:submit property=submit value=Submit/
/td
td align=left
  html:reset/
/td
  /tr

/table

/html:form

/body
/html: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-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 form 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]




How to get data back from ActionForm to HTML form

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

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

form-bean  name=personnelForm
type=blankApp.PersonnelForm/


actionpath=/getpersonnel
   type=blankApp.PersonnelAction
   name=personnelForm
  scope=request
  input=/personnel.jsp 
 forward name=success   path=/personnel.jsp /
/action

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]




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

form-bean  name=personnelForm
type=blankApp.PersonnelForm/


actionpath=/getpersonnel
   type=blankApp.PersonnelAction
   name=personnelForm
  scope=request
  input=/personnel.jsp 
 forward name=success   path=/personnel.jsp /
/action

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]