You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Ned Seagoon <th...@hotmail.com> on 2001/02/20 12:47:43 UTC

help! confused over forms and errors and oooh, other stuff :-)

Hi Guys,

I wonder if you could help me out a little please? I am in the middle of 
developing a proof of concept app with struts. If this comes off the company 
could migrate away from a proprietary framework to struts, which I am in 
favour of.

I seem to have confused myself over an issue regarding validation and forms. 
I’ll give a simplified workflow as an example.

We have for all intents and purposes a generated product overview page along 
these lines:

*Wooden Throat Mallet        59.95 >buy<
*Leather Uncle Frightener    12.60 >buy<
*Vandal-Proof Toupee         99.99 >buy<

Which is generated from struts tags. The >buys< are links to a pages which 
look something like ‘buyit.do?itemid=50’. The buyit.do action has registered 
a form in request scope. During processing, it looks up the full details of 
the itemid and places the resulting bean in request scope. It then creates 
the form object, populates it with some default information and sets this in 
the request too before forwarding onto buypage.jsp

This displays the details of the item, and contains a form for entering, 
say, credit card details:

*Item: Vandal-Proof Toupee
*Manufacturer: Lockheed-Martin Advanced Hairpiece Research
*Price: 99.99
*Additional Information: Also Invisible to Radar
*
* Inside Leg Measurement: _____
* Credit Card Number: ____________________
* >BUY< {forwards onto checkout.do}

Which is all fine and dandy and displays correctly. Though what happens if 
the form validate fails? If checkout.do has an ‘input’ attribute which is 
buypage.jsp then this will fail because the item details are stored on the 
request has not been set up (it was done in ‘buyit.do’). I could of course 
set the item details on the session, but if the user opened new browser 
windows for the ‘buyit’ link, then the session level object will be 
overwritten.

If have looked into placing the details object onto the form bean as it is 
populated, but will that property be preserved across a validate failing? 
And how do I get at the properties of the form bean outside of the 
<hmtl:xxx> tags?

Help !

Regards
Ned



_________________________________________________________________________
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com.


i18 extension was Re: help! confused over forms and errors and oooh, other stuff :-)

Posted by Ned Seagoon <th...@hotmail.com>.
> Ned Seagoon wrote:
> > Yep I believe that struts has a great future. I do believe that it is
the
> > model we should be working with. I am just worried that because of the
> > current limitations that we will not use it. There are whole swathes of
> > stuff that needs to be done, especially when it comes to
> > internationalisation/formatting support when it comes to the view
output,

From: "Craig R. McClanahan" <Cr...@eng.sun.com>
> "Many hands make light work."  Volunteers are welcome to assist :-).

:-) I posted my classes for dealing with this late last year and had no
comment whatsoever about it :-)

To sum up from it: to support local output and view side formatting, I
defined an interface:

public interface LocaleFormatted {
    String toString(FormatInfo formatter) throws JspException;
}

FormatInfo was an object generated by the custom tag writeformatted, which
looked very much bean:write. The FormatInfo object contained locale,
resource bundle and a cache of number formatters. These number formatters
were looked up from definition in the resources (very much like the way that
bean:write works again).

One other feature was that in the tag you could specify a formatInfo text
string. If the object you were trying to print supported LocaleFormatted,
then the formatInfo would contain this string, so your view could specify
say "long" or "short" formats to the object.

If the property was a simple numeric type, then this format info was used to
look up a number format from the app resources.

Anyway, to my mind, *any* call to toString() in the view objects should
*first* try and go to the toString(FormatInfo) version. If you dont try and
do that, then the framework is fatally flawed if you are trying to work with
multile languages or locales. Now to all you guys in the states this may
seem like a side issue (though I think the freedom it allows you
informatting more than makes up for any inconvenience) to us guys in europe
it is a *very* important issue. Just having static localised text resources
supported by bean:message and the like does not cut it. Again, this might be
a flawed solution, but it fixes the problem.

OK, I have also built my own version of bean:message too. Firstly to provide
the argN with LocaleFormatted support, but also to get around the fact that
you cannot nest tags, making using a bean property as a value in
bean:message a no go zone.

I have implemented a simple function that looks at parameter strings and
tries to interpret them, which supports formats like this..

?scope@bean:property
?scope@bean
?bean:property.subproperty[42]
?bean

to do the lookups before doing the format. This is such a lightweight bit of
code (just checking for a ? at the beginning of the string, which, come on,
is vary rarely used) I believe should be run on every attribute that is
marked as 'rtexpr' in the tld. What do you think? You can have this as well
as you like. Remember when I said we should have some kind of source
repository website for people to post their classes? this is why. There must
be other people out there extending who could place some code up there too.

> Until then, I am a little hesitant to commit to any particular logging
API,
> because then we'd have to change it for the standard one later anyway.

OK, I can understand that, but if we are writing code for inclusion in the
project, how do we go about logging?

Regards
Ned

Re: help! confused over forms and errors and oooh, other stuff :-)

Posted by "Craig R. McClanahan" <Cr...@eng.sun.com>.
Ned Seagoon wrote:

> Hi Maya,
>
> Yep I believe that struts has a great future. I do believe that it is the
> model we should be working with. I am just worried that because of the
> current limitations that we will not use it. There are whole swathes of
> stuff that needs to be done, especially when it comes to
> internationalisation/formatting support when it comes to the view output,

"Many hands make light work."  Volunteers are welcome to assist :-).

>
> but that is not a problem. Custom tags can be built to handle what is
> required (as I have done so) but the internal workings of the actionServlet
> is a different matter. If that does not support what you want then you end
> up having to branch away from the codeline (which I don't want to do, it's a
> maintenance nightmare).
>
> We use log4J here. Now that log4j is under the apache wing, I take it that
> tomcat and struts will start to use it at some point?
>

I have been hoping that the JSR for a standard logging API would be done fairly
quickly, so that you could plug in any logging environment you wanted.  I expect
that LOG4J will quickly and easily conform to the new API when it's finalized.

Until then, I am a little hesitant to commit to any particular logging API,
because then we'd have to change it for the standard one later anyway.

>
> Regards
> Ned
>

Craig McClanahan



Re: help! confused over forms and errors and oooh, other stuff :-)

Posted by Ned Seagoon <th...@hotmail.com>.
Hi Maya,

Yep I believe that struts has a great future. I do believe that it is the
model we should be working with. I am just worried that because of the
current limitations that we will not use it. There are whole swathes of
stuff that needs to be done, especially when it comes to
internationalisation/formatting support when it comes to the view output,
but that is not a problem. Custom tags can be built to handle what is
required (as I have done so) but the internal workings of the actionServlet
is a different matter. If that does not support what you want then you end
up having to branch away from the codeline (which I don't want to do, it's a
maintenance nightmare).

We use log4J here. Now that log4j is under the apache wing, I take it that
tomcat and struts will start to use it at some point?

Regards
Ned


----- Original Message -----
From: "Maya Muchnik" <mm...@pumatech.com>
To: <st...@jakarta.apache.org>
Sent: Tuesday, February 20, 2001 11:23 PM
Subject: Re: help! confused over forms and errors and oooh, other stuff :-)


> Hi, Ned,
>
> I am only in the beginning of my project developing, as you are. Tell your
guys
> / managers that this project has a great future. Of course, it is not easy
from
> the first time.
>
> I am sorry, I do not know how resolve your problem, but try to insert a
package
> log4j from jakarta to print out all values / attributes to see where you
loose
> them.
>
> I wish you the best, as for us too. Please, do not panic.
>
> Maya
>
> Ned Seagoon wrote:
>
> > Can nobody give me a clue as to whether I've missed something here? I
have
> > to do a 'show and tell' session on friday where we probably will be
deciding
> > whether to use struts as the basis of future developments. If I'm going
to
> > have to branch away from struts to handle these issues, so be it, but
I'd
> > rather hope they were handled somewhere. Worst case scenario is that we
> > don't use struts at all.
> >
> > Regards
> > Ned
> >
> > ----- Original Message -----
> > From: "Ned Seagoon" <th...@hotmail.com>
> > To: <st...@jakarta.apache.org>
> > Sent: Tuesday, February 20, 2001 11:47 AM
> > Subject: help! confused over forms and errors and oooh, other stuff :-)
> >
> > > Hi Guys,
> > >
> > > I wonder if you could help me out a little please? I am in the middle
of
> > > developing a proof of concept app with struts. If this comes off the
> > company
> > > could migrate away from a proprietary framework to struts, which I am
in
> > > favour of.
> > >
> > > I seem to have confused myself over an issue regarding validation and
> > forms.
> > > I?ll give a simplified workflow as an example.
> > >
> > > We have for all intents and purposes a generated product overview page
> > along
> > > these lines:
> > >
> > > *Wooden Throat Mallet        59.95 >buy<
> > > *Leather Uncle Frightener    12.60 >buy<
> > > *Vandal-Proof Toupee         99.99 >buy<
> > >
> > > Which is generated from struts tags. The >buys< are links to a pages
which
> > > look something like ?buyit.do?itemid=50?. The buyit.do action has
> > registered
> > > a form in request scope. During processing, it looks up the full
details
> > of
> > > the itemid and places the resulting bean in request scope. It then
creates
> > > the form object, populates it with some default information and sets
this
> > in
> > > the request too before forwarding onto buypage.jsp
> > >
> > > This displays the details of the item, and contains a form for
entering,
> > > say, credit card details:
> > >
> > > *Item: Vandal-Proof Toupee
> > > *Manufacturer: Lockheed-Martin Advanced Hairpiece Research
> > > *Price: 99.99
> > > *Additional Information: Also Invisible to Radar
> > > *
> > > * Inside Leg Measurement: _____
> > > * Credit Card Number: ____________________
> > > * >BUY< {forwards onto checkout.do}
> > >
> > > Which is all fine and dandy and displays correctly. Though what
happens if
> > > the form validate fails? If checkout.do has an ?input? attribute which
 is
> > > buypage.jsp then this will fail because the item details are stored on
the
> > > request has not been set up (it was done in ?buyit.do?). I could of
course
> > > set the item details on the session, but if the user opened new
browser
> > > windows for the ?buyit? link, then the session level object will be
> > > overwritten.
> > >
> > > If have looked into placing the details object onto the form bean as
it is
> > > populated, but will that property be preserved across a validate
failing?
> > > And how do I get at the properties of the form bean outside of the
> > > <hmtl:xxx> tags?
> > >
> > > Help !
> > >
> > > Regards
> > > Ned
> > >
> > >
> > >
> > >
_________________________________________________________________________
> > > Get Your Private, Free E-mail from MSN Hotmail at
http://www.hotmail.com.
> > >
> > >
>
>

Re: help! confused over forms and errors and oooh, other stuff :-)

Posted by Maya Muchnik <mm...@pumatech.com>.
Hi, Ned,

I am only in the beginning of my project developing, as you are. Tell your guys
/ managers that this project has a great future. Of course, it is not easy from
the first time.

I am sorry, I do not know how resolve your problem, but try to insert a package
log4j from jakarta to print out all values / attributes to see where you loose
them.

I wish you the best, as for us too. Please, do not panic.

Maya

Ned Seagoon wrote:

> Can nobody give me a clue as to whether I've missed something here? I have
> to do a 'show and tell' session on friday where we probably will be deciding
> whether to use struts as the basis of future developments. If I'm going to
> have to branch away from struts to handle these issues, so be it, but I'd
> rather hope they were handled somewhere. Worst case scenario is that we
> don't use struts at all.
>
> Regards
> Ned
>
> ----- Original Message -----
> From: "Ned Seagoon" <th...@hotmail.com>
> To: <st...@jakarta.apache.org>
> Sent: Tuesday, February 20, 2001 11:47 AM
> Subject: help! confused over forms and errors and oooh, other stuff :-)
>
> > Hi Guys,
> >
> > I wonder if you could help me out a little please? I am in the middle of
> > developing a proof of concept app with struts. If this comes off the
> company
> > could migrate away from a proprietary framework to struts, which I am in
> > favour of.
> >
> > I seem to have confused myself over an issue regarding validation and
> forms.
> > I?ll give a simplified workflow as an example.
> >
> > We have for all intents and purposes a generated product overview page
> along
> > these lines:
> >
> > *Wooden Throat Mallet        59.95 >buy<
> > *Leather Uncle Frightener    12.60 >buy<
> > *Vandal-Proof Toupee         99.99 >buy<
> >
> > Which is generated from struts tags. The >buys< are links to a pages which
> > look something like ?buyit.do?itemid=50?. The buyit.do action has
> registered
> > a form in request scope. During processing, it looks up the full details
> of
> > the itemid and places the resulting bean in request scope. It then creates
> > the form object, populates it with some default information and sets this
> in
> > the request too before forwarding onto buypage.jsp
> >
> > This displays the details of the item, and contains a form for entering,
> > say, credit card details:
> >
> > *Item: Vandal-Proof Toupee
> > *Manufacturer: Lockheed-Martin Advanced Hairpiece Research
> > *Price: 99.99
> > *Additional Information: Also Invisible to Radar
> > *
> > * Inside Leg Measurement: _____
> > * Credit Card Number: ____________________
> > * >BUY< {forwards onto checkout.do}
> >
> > Which is all fine and dandy and displays correctly. Though what happens if
> > the form validate fails? If checkout.do has an ?input? attribute which is
> > buypage.jsp then this will fail because the item details are stored on the
> > request has not been set up (it was done in ?buyit.do?). I could of course
> > set the item details on the session, but if the user opened new browser
> > windows for the ?buyit? link, then the session level object will be
> > overwritten.
> >
> > If have looked into placing the details object onto the form bean as it is
> > populated, but will that property be preserved across a validate failing?
> > And how do I get at the properties of the form bean outside of the
> > <hmtl:xxx> tags?
> >
> > Help !
> >
> > Regards
> > Ned
> >
> >
> >
> > _________________________________________________________________________
> > Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com.
> >
> >


Re: help! confused over forms and errors and oooh, other stuff :-)

Posted by Ned Seagoon <th...@hotmail.com>.
Can nobody give me a clue as to whether I've missed something here? I have
to do a 'show and tell' session on friday where we probably will be deciding
whether to use struts as the basis of future developments. If I'm going to
have to branch away from struts to handle these issues, so be it, but I'd
rather hope they were handled somewhere. Worst case scenario is that we
don't use struts at all.

Regards
Ned

----- Original Message -----
From: "Ned Seagoon" <th...@hotmail.com>
To: <st...@jakarta.apache.org>
Sent: Tuesday, February 20, 2001 11:47 AM
Subject: help! confused over forms and errors and oooh, other stuff :-)


> Hi Guys,
>
> I wonder if you could help me out a little please? I am in the middle of
> developing a proof of concept app with struts. If this comes off the
company
> could migrate away from a proprietary framework to struts, which I am in
> favour of.
>
> I seem to have confused myself over an issue regarding validation and
forms.
> I’ll give a simplified workflow as an example.
>
> We have for all intents and purposes a generated product overview page
along
> these lines:
>
> *Wooden Throat Mallet        59.95 >buy<
> *Leather Uncle Frightener    12.60 >buy<
> *Vandal-Proof Toupee         99.99 >buy<
>
> Which is generated from struts tags. The >buys< are links to a pages which
> look something like ‘buyit.do?itemid=50’. The buyit.do action has
registered
> a form in request scope. During processing, it looks up the full details
of
> the itemid and places the resulting bean in request scope. It then creates
> the form object, populates it with some default information and sets this
in
> the request too before forwarding onto buypage.jsp
>
> This displays the details of the item, and contains a form for entering,
> say, credit card details:
>
> *Item: Vandal-Proof Toupee
> *Manufacturer: Lockheed-Martin Advanced Hairpiece Research
> *Price: 99.99
> *Additional Information: Also Invisible to Radar
> *
> * Inside Leg Measurement: _____
> * Credit Card Number: ____________________
> * >BUY< {forwards onto checkout.do}
>
> Which is all fine and dandy and displays correctly. Though what happens if
> the form validate fails? If checkout.do has an ‘input’ attribute which is
> buypage.jsp then this will fail because the item details are stored on the
> request has not been set up (it was done in ‘buyit.do’). I could of course
> set the item details on the session, but if the user opened new browser
> windows for the ‘buyit’ link, then the session level object will be
> overwritten.
>
> If have looked into placing the details object onto the form bean as it is
> populated, but will that property be preserved across a validate failing?
> And how do I get at the properties of the form bean outside of the
> <hmtl:xxx> tags?
>
> Help !
>
> Regards
> Ned
>
>
>
> _________________________________________________________________________
> Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com.
>
>

RE: help! confused over forms and errors and oooh, other stuff :-)

Posted by "Jason H. Kim" <ja...@qett.com>.
You can access the properties of the form bean by using jsp:bean or just do

<%
	// if the bean was submitted in request scope.
	formBean asdf = request.getAttribute("the key you used - or name attribute
of youe struts form tag.");
%>

even if the validation failse and you used request, your bean properties
will be preserved.

Thank you.

Jason H. Kim
Quatrix Emerging Technology Team
Phone: 314-993-5858 EXT: 137

-----Original Message-----
From: Ned Seagoon [mailto:therealneddyseagoon@hotmail.com]
Sent: Tuesday, February 20, 2001 5:48 AM
To: struts-user@jakarta.apache.org
Subject: help! confused over forms and errors and oooh, other stuff :-)


Hi Guys,

I wonder if you could help me out a little please? I am in the middle of
developing a proof of concept app with struts. If this comes off the company
could migrate away from a proprietary framework to struts, which I am in
favour of.

I seem to have confused myself over an issue regarding validation and forms.
I’ll give a simplified workflow as an example.

We have for all intents and purposes a generated product overview page along
these lines:

*Wooden Throat Mallet        59.95 >buy<
*Leather Uncle Frightener    12.60 >buy<
*Vandal-Proof Toupee         99.99 >buy<

Which is generated from struts tags. The >buys< are links to a pages which
look something like ‘buyit.do?itemid=50’. The buyit.do action has registered
a form in request scope. During processing, it looks up the full details of
the itemid and places the resulting bean in request scope. It then creates
the form object, populates it with some default information and sets this in
the request too before forwarding onto buypage.jsp

This displays the details of the item, and contains a form for entering,
say, credit card details:

*Item: Vandal-Proof Toupee
*Manufacturer: Lockheed-Martin Advanced Hairpiece Research
*Price: 99.99
*Additional Information: Also Invisible to Radar
*
* Inside Leg Measurement: _____
* Credit Card Number: ____________________
* >BUY< {forwards onto checkout.do}

Which is all fine and dandy and displays correctly. Though what happens if
the form validate fails? If checkout.do has an ‘input’ attribute which is
buypage.jsp then this will fail because the item details are stored on the
request has not been set up (it was done in ‘buyit.do’). I could of course
set the item details on the session, but if the user opened new browser
windows for the ‘buyit’ link, then the session level object will be
overwritten.

If have looked into placing the details object onto the form bean as it is
populated, but will that property be preserved across a validate failing?
And how do I get at the properties of the form bean outside of the
<hmtl:xxx> tags?

Help !

Regards
Ned



_________________________________________________________________________
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com.