RE: map-backed forms example

2004-02-28 Thread Sharad Acharya
Jared;
*** You can have your JSP display it's contents dynamically. For this you 
can use map or list backed forms. But keep in mind that you need to populate 
such maps or lists before you can display in your JSP.
*** Your action form is available in your action class. Look at one of the 
the parameters passed to execute(...) method in your action class. You need 
to downcast to exact form type though. The contents of the form is available 
in your action class's execute method. But keep in mind that following 
sequence happen exactly in that sequence:
1. call reset method in your action form if you have overridden it.
2. populate your action form fields with matching HttpServletRequest 
attributes.
3. call validate method if overridden.
After this, execute mthod returns which is the last point that you can 
manipulate your data. So in action form's execute method you can see the 
data populated based on your form submitted. Once execute returns, struts 
takes control and forwards to the appropriate page.

So, you need to populate your form before you can display the text boxes 
with the JSP. But keep in mind that the form fields name match with the 
request atrtribute name, then you can manipulate if action class ify you 
want. If the names does not match, you will not the data your form has 
posted.

Let me know if you still have confusion.

Sharad Acharya




From: Jared Blitzstein [EMAIL PROTECTED]
Reply-To: [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Subject: map-backed forms example
Date: Fri, 27 Feb 2004 15:51:29 -0800 (PST)
I've been searching the archive and google or an
example of a map-backed form similar to what i'm
trying to accomplish, but I haven't found anything.
What i'm trying to do is this:
somePage.jsp has a dynamic number textboxes on it,
some i know the exact name of (color) and some I
just know what they start with (attribute_1,
attribute_2...etc). It submits to ProcessMyData.do
which does some back end processing on those form
elements, then forwards to another JSP. I can't seem
to access the data from the form in the action.
All the examples I have found go directly to a JSP for
display, nothing in the action. Can anyone show me an
example (form, action, config.xml) of how to pass in a
few textboxes, get that data in an action, and then
forward (last step not that important).
Thanks alot.
If you need any more info or anything else from me,
let me know.
__
Do you Yahoo!?
Get better spam protection with Yahoo! Mail.
http://antispam.yahoo.com/tools
-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
_
Store more e-mails with MSN Hotmail Extra Storage – 4 plans to choose from! 
http://click.atdmt.com/AVE/go/onm00200362ave/direct/01/

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


RE: bean:write not writing?

2003-12-27 Thread Sharad Acharya
Michael;
Did you forget to specify the taglib directive for bean:write tag library in 
your JSP? In such case, have following in your JSP.

%@ taglib uri=/WEB-INF/struts-bean.tld prefix=bean %

Hope this helps.
Sharad



From: Michael Marrotte [EMAIL PROTECTED]
Reply-To: [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Subject: bean:write not writing?
Date: Sat, 27 Dec 2003 08:51:18 -0500
Here's the bean:

public class Cart extends HashMap {
private double subTotal = 400.00;
public double getSubTotal(){return subTotal;}
}
Here's the Java:

session.setAttribute(cart, new Cart());

Here's the JSP

bean:write name=cart property=subTotal/ // no output?
%= ((csp.Cart)session.getAttribute(cart)).getSubTotal() % // works,
writes 400.0
Here's the problem

bean:write isn't producing any output, but

%= ... % is...

Any ideas are greatly appreciated.

Thanks,

--Mike M.

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
_
Tired of slow downloads? Compare online deals from your local high-speed 
providers now.  https://broadband.msn.com

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


Handle dynamic contents using map backed form

2003-12-10 Thread Sharad Acharya
Hi all;
From Ted and others comments, it looks like some of you are trying to 
implement forms that should handle 'real' dynamic contents. In my recent 
project, I had pleasure to work handling dynamic contents in which the 
contents to render were not available until the time to render. 
DynaActionForm does not help because we need to fix form attributes in 
configuration element. Sooo the solution? we implemented map backed forms. I 
have discussed the technique in my recent JavaPro article, which you can 
read online in the following links:

Part I:
http://www.fawcette.com/javapro/2003_11/online/dynamic_sacharya_11_11_03/
Part II:
http://www.fawcette.com/javapro/2003_11/online/dynamic_sacharya_11_17_03/
If you have any question about my approach, please let me know.

Thanks

Sharad Acharya



From: Ted Husted [EMAIL PROTECTED]
Reply-To: Struts Users Mailing List [EMAIL PROTECTED]
To: Struts Users Mailing List [EMAIL PROTECTED]
Subject: Re: When HashMap will replace ActionForm ?
Date: Wed, 10 Dec 2003 13:01:55 -0500
As mentioned, you can use a map-backed ActionForm to store whatever fields 
you need without defining them elsewhere.

http://tinyurl.com/ymkr

You do need to code the forms a little differently, and your forms still 
need to know what properties/entries to ask for.

Personally, I would strongly recommnend using DynaActionForms. The overhead 
of defining the elements in the configuration is negligable in practice, 
and it clearly defines which properties are used with which forms.

In practice, what really costs projects time is miscommunication. For 
example, is the entry name in the Map userName or username? With 
DynaActionForms all the entry names are documented in the configuration. 
Otherwise, you will have to document them elsewhere and redo what has 
already been done.

I *am* a big fan of using Maps for Contexts, especially between application 
layers, and with the Commons Chain influence, we're sure to see more of 
that. The thing about DynaActionForms is that you get the agility of a Map 
with the documentation of a JavaBean.

HTH, Ted.

Antony Paul wrote:
but it prints the form field name like this map(username). I want to get 
the
key as name of form field. here username. possible ?

rgds
Antony Paul.
- Original Message -
From: Fullam, Jonathan [EMAIL PROTECTED]
To: 'Struts Users Mailing List' [EMAIL PROTECTED]
Sent: Wednesday, December 10, 2003 7:30 PM
Subject: RE: When HashMap will replace ActionForm ?


That's where a map-backed Hashmap is useful.

-Original Message-
From: Antony Paul [mailto:[EMAIL PROTECTED]
Sent: Wednesday, December 10, 2003 6:02 AM
To: Struts Users Mailing List
Subject: Re: When HashMap will replace ActionForm ?
I know that but one have to define 10 to 30 elements in struts-config.xml
for that. With a hash map one have to say whether it is needed ot not. It
could be accessed like DynaValidator form. And my requirement is to store
simple text field values.
rgds
Antony Paul.
- Original Message -
From: Kalra, Ashwani [EMAIL PROTECTED]
To: Struts Users Mailing List [EMAIL PROTECTED]
Sent: Wednesday, December 10, 2003 4:05 PM
Subject: RE: When HashMap will replace ActionForm ?


DynaValidator forms stores data in Hashmap internally if you dont want
to

define norma action forms.





-Original Message-
From: Antony Paul [mailto:[EMAIL PROTECTED]
Sent: Wednesday, December 10, 2003 2:40 PM
To: struts
Subject: When HashMap will replace ActionForm ?
Hi,
  Is there any move to support HashMap in place of
ActionForm ?. I dont
want to start any argument. I have read a lot on ActionForm in
this archive.
rgds
Antony Paul.
-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

This message contains information that may be privileged or confidential
and

is the property of the Cap Gemini Ernst  Young Group. It is intended
only

for the person to whom it is addressed. If you are not the intended
recipient, you are not authorised to read, print, retain, copy,
disseminate,

distribute, or use this message or any part thereof. If you receive this
message in error, please notify the sender immediately and delete all
copies

of this message.

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

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


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



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