You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Jakub Królikowski <ku...@kompakt.pl> on 2005/11/18 19:56:52 UTC
Action - redirect to same page with GET method
Hello!
I'm new in Struts.
I don't know how to write such code using Struts (version in html):
<html>
<head>
<title>Simple Forward</title>
</head>
<body>
You can rename the source html file and it allways will works!!!
<br>
<form name="test" method="get" onsubmit="javascript:
this.action=document.location">
type a text and type "Enter" : <input type="text" name="text">
</form>
</body>
</html>
You can put it into any .html file and named it as you want - it will
allways works.
I want to use Struts Action and Struts Form - I want to handle form
values in action servlet. I don't know how to forward in action to input
page, when I don't know its name? After that I need all form parameters
to be printed in url - like in my example which simply uses GET submit
method. How to do it with Struts Action?
Jakub Królikowski
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: Action - redirect to same page with GET method
Posted by Laurie Harper <la...@holoweb.net>.
Kuba Królikowski wrote:
> Laurie Harper napisał(a):
>
>> Jakub Królikowski wrote:
>>
>>> Hello!
>>>
>>> I'm new in Struts.
>>>
>>> I don't know how to write such code using Struts (version in html):
>>>
>>> <html>
>>> <head>
>>> <title>Simple Forward</title>
>>> </head>
>>> <body>
>>> You can rename the source html file and it allways will works!!!
>>> <br>
>>> <form name="test" method="get" onsubmit="javascript:
>>> this.action=document.location">
>>> type a text and type "Enter" : <input type="text" name="text">
>>> </form>
>>> </body>
>>> </html>
>>>
>>> You can put it into any .html file and named it as you want - it will
>>> allways works.
>>>
>>> I want to use Struts Action and Struts Form - I want to handle form
>>> values in action servlet. I don't know how to forward in action to
>>> input page, when I don't know its name? After that I need all form
>>> parameters to be printed in url - like in my example which simply
>>> uses GET submit method. How to do it with Struts Action?
>>
>>
>>
>> I'm not sure I followed all that. To answer the question I can see:
>>
>> - to forward to the input page in an action, use code like the following:
>>
>> return mapping.getInputForward();
>>
>> You define what the 'input page' is with the 'input' attribute of your
>> action mapping in struts-config.xml. By default, this will do a
>> server-side redirect, so the browser's location bar will keep whatever
>> URL it had to invoke your action.
>>
>> L..
>>
>>
>
> But the input page in struts-config.xml cannot be set dynamicaly. I don't
> know the name of input page. It could be whatever, it will change. Any
> idea?
There's no reliable way to find out what page you were on before the
current page, unfortunately. You have to track that somehow yourself.
L.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: Action - redirect to same page with GET method
Posted by Kuba Królikowski <ku...@kompakt.pl>.
Laurie Harper napisał(a):
> Jakub Królikowski wrote:
>
>> Hello!
>>
>> I'm new in Struts.
>>
>> I don't know how to write such code using Struts (version in html):
>>
>> <html>
>> <head>
>> <title>Simple Forward</title>
>> </head>
>> <body>
>> You can rename the source html file and it allways will works!!!
>> <br>
>> <form name="test" method="get" onsubmit="javascript:
>> this.action=document.location">
>> type a text and type "Enter" : <input type="text" name="text">
>> </form>
>> </body>
>> </html>
>>
>> You can put it into any .html file and named it as you want - it will
>> allways works.
>>
>> I want to use Struts Action and Struts Form - I want to handle form
>> values in action servlet. I don't know how to forward in action to
>> input page, when I don't know its name? After that I need all form
>> parameters to be printed in url - like in my example which simply uses
>> GET submit method. How to do it with Struts Action?
>
>
> I'm not sure I followed all that. To answer the question I can see:
>
> - to forward to the input page in an action, use code like the following:
>
> return mapping.getInputForward();
>
> You define what the 'input page' is with the 'input' attribute of your
> action mapping in struts-config.xml. By default, this will do a
> server-side redirect, so the browser's location bar will keep whatever
> URL it had to invoke your action.
>
> L..
>
>
But the input page in struts-config.xml cannot be set dynamicaly. I don't
know the name of input page. It could be whatever, it will change. Any
idea?
K.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: Action - redirect to same page with GET method
Posted by Laurie Harper <la...@holoweb.net>.
Jakub Królikowski wrote:
> Hello!
>
> I'm new in Struts.
>
> I don't know how to write such code using Struts (version in html):
>
> <html>
> <head>
> <title>Simple Forward</title>
> </head>
> <body>
> You can rename the source html file and it allways will works!!!
> <br>
> <form name="test" method="get" onsubmit="javascript:
> this.action=document.location">
> type a text and type "Enter" : <input type="text" name="text">
> </form>
> </body>
> </html>
>
> You can put it into any .html file and named it as you want - it will
> allways works.
>
> I want to use Struts Action and Struts Form - I want to handle form
> values in action servlet. I don't know how to forward in action to input
> page, when I don't know its name? After that I need all form parameters
> to be printed in url - like in my example which simply uses GET submit
> method. How to do it with Struts Action?
I'm not sure I followed all that. To answer the question I can see:
- to forward to the input page in an action, use code like the following:
return mapping.getInputForward();
You define what the 'input page' is with the 'input' attribute of your
action mapping in struts-config.xml. By default, this will do a
server-side redirect, so the browser's location bar will keep whatever
URL it had to invoke your action.
L..
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: Is there an easy way to print error messages
Posted by Martin Gainty <mg...@hotmail.com>.
*Assuming* ApplicationResources.properties contains
In the ApplicationResources.properties:
errors.email=<font color="red"><strong>invalid e-mail
address.</strong></font>
If your key value isnt pointing to errors.email then it should be pointing
to a bundle specification for your ApplicationResources file which contains
that key
<message-resources bundle="label.screen3.emailAddress"
parameter="ApplicationResources"/>
/*Now specify the exact key parameter to reference in the bundle in your
jsp*/
<bean:message bundle="label.screen3.emailAddress" key="errors.email"/>
HTH,
Martin-
----- Original Message -----
From: <bs...@psl.nmsu.edu>
To: <us...@struts.apache.org>
Sent: Friday, November 18, 2005 3:52 PM
Subject: RE: Is there an easy way to print error messages
Yeah, I do it this way:
In the ApplicationResources.properties:
errors.email=<font color="red"><strong>invalid e-mail
address.</strong></font>
And in the jsp:
<tr>
<td width="200" align="right"><bean:message
key="label.screen3.emailAddress"/>:</td>
<td><html:text property="emailAddress"/></td><td><html:errors
property="emailAddress"/></td>
</tr>
On 11/18/05, Aladin Alaily <st...@aladin.ca> wrote:
> Problem solved... must be Friday.
>
> Aladin
>
>
> > Hello,
> >
> > I am using struts 1.2.7 and am having trouble outputing error messages
> > for
> > specific fields.
> >
> > If I have the following (in a form):
> >
> > <html:input property="name" />
> >
> > and in my action I do something like:
> >
> > messages.add("name", new ActionMessage("error.name.required"));
> > super.saveErrors(request.getSession(), messages);
> >
> >
> > Now, I would expect that the error message be outputted to the right of
> > the textfield (<input..> Error message here), but it doesn't.
> >
> > Does anyone know if things have changed in 1.2.7... or am I missing
> > something here?
> >
> > Thanks!
> > Aladin
> >
> >
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
RE: Is there an easy way to print error messages
Posted by bs...@psl.nmsu.edu.
Yeah, I do it this way:
In the ApplicationResources.properties:
errors.email=<font color="red"><strong>invalid e-mail address.</strong></font>
And in the jsp:
<tr>
<td width="200" align="right"><bean:message key="label.screen3.emailAddress"/>:</td>
<td><html:text property="emailAddress"/></td><td><html:errors property="emailAddress"/></td>
</tr>
On 11/18/05, Aladin Alaily <st...@aladin.ca> wrote:
> Problem solved... must be Friday.
>
> Aladin
>
>
> > Hello,
> >
> > I am using struts 1.2.7 and am having trouble outputing error messages for
> > specific fields.
> >
> > If I have the following (in a form):
> >
> > <html:input property="name" />
> >
> > and in my action I do something like:
> >
> > messages.add("name", new ActionMessage("error.name.required"));
> > super.saveErrors(request.getSession(), messages);
> >
> >
> > Now, I would expect that the error message be outputted to the right of
> > the textfield (<input..> Error message here), but it doesn't.
> >
> > Does anyone know if things have changed in 1.2.7... or am I missing
> > something here?
> >
> > Thanks!
> > Aladin
> >
> >
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: Is there an easy way to print error messages
Posted by Hubert Rabago <hr...@gmail.com>.
Yes it's Friday indeed (TG). For the benefit of you out there
searching the archives, you can accomplish this by using <html:errors
property="name" /> . You can get more information here:
http://www.niallp.pwp.blueyonder.co.uk/HelpTagsErrorsAndMessages.html
Hubert
On 11/18/05, Aladin Alaily <st...@aladin.ca> wrote:
> Problem solved... must be Friday.
>
> Aladin
>
>
> > Hello,
> >
> > I am using struts 1.2.7 and am having trouble outputing error messages for
> > specific fields.
> >
> > If I have the following (in a form):
> >
> > <html:input property="name" />
> >
> > and in my action I do something like:
> >
> > messages.add("name", new ActionMessage("error.name.required"));
> > super.saveErrors(request.getSession(), messages);
> >
> >
> > Now, I would expect that the error message be outputted to the right of
> > the textfield (<input..> Error message here), but it doesn't.
> >
> > Does anyone know if things have changed in 1.2.7... or am I missing
> > something here?
> >
> > Thanks!
> > Aladin
> >
> >
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: Is there an easy way to print error messages
Posted by Aladin Alaily <st...@aladin.ca>.
Problem solved... must be Friday.
Aladin
> Hello,
>
> I am using struts 1.2.7 and am having trouble outputing error messages for
> specific fields.
>
> If I have the following (in a form):
>
> <html:input property="name" />
>
> and in my action I do something like:
>
> messages.add("name", new ActionMessage("error.name.required"));
> super.saveErrors(request.getSession(), messages);
>
>
> Now, I would expect that the error message be outputted to the right of
> the textfield (<input..> Error message here), but it doesn't.
>
> Does anyone know if things have changed in 1.2.7... or am I missing
> something here?
>
> Thanks!
> Aladin
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Is there an easy way to print error messages
Posted by Aladin Alaily <st...@aladin.ca>.
Hello,
I am using struts 1.2.7 and am having trouble outputing error messages for
specific fields.
If I have the following (in a form):
<html:input property="name" />
and in my action I do something like:
messages.add("name", new ActionMessage("error.name.required"));
super.saveErrors(request.getSession(), messages);
Now, I would expect that the error message be outputted to the right of
the textfield (<input..> Error message here), but it doesn't.
Does anyone know if things have changed in 1.2.7... or am I missing
something here?
Thanks!
Aladin
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org