You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Yariel Ramos Moreno <yr...@ceis.cujae.edu.cu> on 2006/11/03 21:09:07 UTC

Two values on "input" attribute

Hi all:

I have a page validated with Validation Framework, but I can get that page from two diferent jsp inputs. When an error ocurs, the validator always turn me back to the same jsp input (the one especified) not matter which was the selected input. It is possible to set two values to "input" attribute in an ActionMapping?? Is there any other way to do something like that??

Best regards.
__________________________________________

XIII Convención Científica de Ingeniería y Arquitectura
28/noviembre al 1/diciembre de 2006
Cujae, Ciudad de la Habana, Cuba
http://www.cujae.edu.cu/eventos/convencion

Re: Two values on "input" attribute

Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Thom,

Thom Burnett wrote:
> First, I found my error and it's (of course) not in any of the code listed.
> I had neglected the import statements in the jsp pages. :-(

That always helps. So, your JSPs weren't compiling or something? It's
odd that it would "work", and yet, not work.

> Is there a way to get warnings or error messages when I've made a mistake
> like this in the jsp?

JSP compilation errors should show up right in the page. When something
like this happens, it's best to shutdown Tomcat, kill your "work"
directory and any expanded WAR files (usually killing the work dir does
that), and re-starting. It doesn't happen often, but sometimes TC goes
brain-dead and you just have to lobotomize it.

> In my build there was no compiler error or warning. Finding this type of
> error by inspection is very time consuming.

Certainly, and this is not the way it should work. I suspect that there
was a datestamp issue so it looked like the already-compiled version of
your JSP was more up-to-date than your new version.

Do a clean build and re-start and I think you'll find that TC will
report those compilation errors.

- -chris

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFFUk1/9CaO5/Lv0PARAjLXAJ9/xvNULda5/ULRXnMbHlImlkzghACcD1PL
Ky8IDaNaMIAELu37uNl38Sc=
=INdL
-----END PGP SIGNATURE-----

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


Re: Two values on "input" attribute

Posted by Martin Gainty <mg...@hotmail.com>.
The simplest way to show the error in browser is to capture the OutputStream for the Response Object and stream the exception code,/desc/whatever back to the user as in this example-

response.getOutputStream().out("Exception text is "+excp.getMessage());
if you want to dress it up you can use css stylesheets/fonts/colors etc

Anyone else?
M-
This e-mail communication and any attachments may contain confidential and privileged information for the use of the 
designated recipients named above. If you are not the intended recipient, you are hereby notified that you have received
this communication in error and that any review, disclosure, dissemination, distribution or copying of it or its 
contents
----- Original Message ----- 
From: "Thom Burnett" <th...@gmail.com>
To: "Struts Users Mailing List" <us...@struts.apache.org>
Sent: Wednesday, November 08, 2006 1:07 PM
Subject: Re: Two values on "input" attribute


> First, I found my error and it's (of course) not in any of the code listed.
> I had neglected the import statements in the jsp pages. :-(
> So you can ignore this question but it does bring up another one.
> 
> Is there a way to get warnings or error messages when I've made a mistake
> like this in the jsp?
> In my build there was no compiler error or warning. Finding this type of
> error by inspection is very time consuming.
> 
> On 11/8/06, Thom Burnett <th...@gmail.com> wrote:
>>
>> I tried this technique for my situation where several jsp pages contribute
>> to one ActionForm.
>> I'm getting the correct page selection behavior by my errors don't show
>> up.
>>
>> For the first page (the donation page) everything works very nicely.
>> For the second page (the honoree page) there's no trace of an error
>> message.
>>
>> That is, when (and only when) there's an error, the page will not continue
>> on to the next page but
>> the <html:errors/> tag seems to return no contents - that part of the
>> displayed page is blank.
>>
>> I can't see any meaningful difference between the two pages. Is this a
>> question of where the ActionErrors instance is stored?
>>
>>
>>
>>
>> struts-config
>> ...
>>     <action path="/donation3"   type="
>> com.softrek.donation.DonationAction3"
>>             name="donorBean" scope="session"
>>             input="/donation3.jsp" validate="true">
>>       <forward name="oracleError"  path="/oracleError3.jsp"/>
>>       <forward name="success"      path="/thankYou3.jsp"/>
>>       <forward name="firstPage"    path="/donation3.jsp"/>
>>       <forward name="secondPage"   path="/honoree3.jsp"/>
>>       <forward name="thirdPage"    path="/payment3.jsp"/>
>>     </action>
>>     <action path="/honoree3"   type="com.softrek.donation.DonationAction3"
>>             name="donorBean" scope="session"
>>             input="/honoree3.jsp"  validate="true">
>>       <forward name="oracleError"  path="/oracleError3.jsp"/>
>>       <forward name="success"      path="/thankYou3.jsp"/>
>>       <forward name="firstPage"    path="/donation3.jsp"/>
>>       <forward name="secondPage"   path="/honoree3.jsp"/>
>>       <forward name="thirdPage"    path="/payment3.jsp"/>
>>     </action>
>> ...
>>
>> donation3.jsp page
>>
>> ...
>> <% AllDonationInformationFormBean3 donorBean =
>> (AllDonationInformationFormBean3)session.getAttribute("donorBean") ;
>>      if(donorBean == null) donorBean = new
>> AllDonationInformationFormBean3() ;
>>   %>
>>   <body>
>>     <center>
>>       <h1>New Account Registration</h1>
>>     </center>
>>     <form action="../donation3/donation3.do" method="post">
>>       <input type="hidden" name="pagename" value="donationPage"/>
>>       <input type="hidden" name="page" value="1"/>
>>       <p style="background-color:rgb(0,255,255); font-size:large;">Donor
>> Information</p>
>>       <html:errors/><br/>
>>       <p>*Indicates required field</p>
>> ...
>>
>> honoree3.jsp page
>>
>> ...
>> <% AllDonationInformationFormBean3 donorBean =
>> (AllDonationInformationFormBean3)session.getAttribute("donorBean") ;
>>      if(donorBean == null) donorBean = new
>> AllDonationInformationFormBean3() ;
>>      %>
>>
>> <html>
>>   <head>
>>     <meta http-equiv="Content-Type" content="text/html;
>> charset=windows-1252">
>>     <title>Honor of</title>
>>   </head>
>>   <body>
>>     <center>
>>       <h1>In Honor Of</h1>
>>     </center>
>>     <form action="../donation3/honoree3.do" method="post">
>>       <input type="hidden" name="pagename" value="honoreePage"/>
>>       <input type="hidden" name="page" value="2"/>
>>       <P style="background-color:rgb(0,255,255); font-size:large;">In
>> Honor of:</P>
>>       <P>*Indicates required field</P>
>>       <html:errors/><br/>
>> ...
>>
>>
>> On 11/4/06, Christopher Schultz <chris@christopherschultz.net > wrote:
>> >
>> > -----BEGIN PGP SIGNED MESSAGE-----
>> > Hash: SHA1
>> >
>> > Yariel,
>> >
>> > > I have a page validated with Validation Framework, but I can get that
>> > > page from two diferent jsp inputs. When an error ocurs, the validator
>> > > always turn me back to the same jsp input (the one especified) not
>> > > matter which was the selected input. It is possible to set two values
>> > > to "input" attribute in an ActionMapping?? Is there any other way to
>> > > do something like that??
>> >
>> >
>> > Generally, this is done with two separate ActionMappings, like this:
>> >
>> > <!-- submit to here from first.jsp -->
>> > <action path="/path1"
>> >     type="MyAction"
>> >     name="MyFormBean"
>> >     validate="true"
>> >     scope="request"
>> >     input="/first.jsp">
>> >   ...
>> > </action>
>> >
>> > <!-- submit to here from second.jsp -->
>> > <action path="/path2"
>> >     type="MyAction"
>> >     name="MyFormBean"
>> >     validate="true"
>> >     scope="request"
>> >     input="/second.jsp">
>> >   ...
>> > </action>
>> >
>> > You are doing the exact same thing in both cases, except that the
>> > "input" attributes are different. The validation should be the same,
>> > using the same form bean, etc.
>> >
>> > Hope that helps,
>> > - -chris
>> > -----BEGIN PGP SIGNATURE-----
>> > Version: GnuPG v1.4.5 (MingW32)
>> > Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
>> >
>> > iD8DBQFFTJOE9CaO5/Lv0PARArvPAJ9/6S//E9jkQFVy/QC2mIGUTMBgAACgr4d2
>> > NY36tWCeaj9w/2bBwcBpKKY=
>> > =CJAz
>> > -----END PGP SIGNATURE-----
>> >
>> > ---------------------------------------------------------------------
>> > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> > For additional commands, e-mail: user-help@struts.apache.org
>> >
>> >
>>
>

Re: Two values on "input" attribute

Posted by Thom Burnett <th...@gmail.com>.
First, I found my error and it's (of course) not in any of the code listed.
I had neglected the import statements in the jsp pages. :-(
So you can ignore this question but it does bring up another one.

Is there a way to get warnings or error messages when I've made a mistake
like this in the jsp?
In my build there was no compiler error or warning. Finding this type of
error by inspection is very time consuming.

On 11/8/06, Thom Burnett <th...@gmail.com> wrote:
>
> I tried this technique for my situation where several jsp pages contribute
> to one ActionForm.
> I'm getting the correct page selection behavior by my errors don't show
> up.
>
> For the first page (the donation page) everything works very nicely.
> For the second page (the honoree page) there's no trace of an error
> message.
>
> That is, when (and only when) there's an error, the page will not continue
> on to the next page but
> the <html:errors/> tag seems to return no contents - that part of the
> displayed page is blank.
>
> I can't see any meaningful difference between the two pages. Is this a
> question of where the ActionErrors instance is stored?
>
>
>
>
> struts-config
> ...
>     <action path="/donation3"   type="
> com.softrek.donation.DonationAction3"
>             name="donorBean" scope="session"
>             input="/donation3.jsp" validate="true">
>       <forward name="oracleError"  path="/oracleError3.jsp"/>
>       <forward name="success"      path="/thankYou3.jsp"/>
>       <forward name="firstPage"    path="/donation3.jsp"/>
>       <forward name="secondPage"   path="/honoree3.jsp"/>
>       <forward name="thirdPage"    path="/payment3.jsp"/>
>     </action>
>     <action path="/honoree3"   type="com.softrek.donation.DonationAction3"
>             name="donorBean" scope="session"
>             input="/honoree3.jsp"  validate="true">
>       <forward name="oracleError"  path="/oracleError3.jsp"/>
>       <forward name="success"      path="/thankYou3.jsp"/>
>       <forward name="firstPage"    path="/donation3.jsp"/>
>       <forward name="secondPage"   path="/honoree3.jsp"/>
>       <forward name="thirdPage"    path="/payment3.jsp"/>
>     </action>
> ...
>
> donation3.jsp page
>
> ...
> <% AllDonationInformationFormBean3 donorBean =
> (AllDonationInformationFormBean3)session.getAttribute("donorBean") ;
>      if(donorBean == null) donorBean = new
> AllDonationInformationFormBean3() ;
>   %>
>   <body>
>     <center>
>       <h1>New Account Registration</h1>
>     </center>
>     <form action="../donation3/donation3.do" method="post">
>       <input type="hidden" name="pagename" value="donationPage"/>
>       <input type="hidden" name="page" value="1"/>
>       <p style="background-color:rgb(0,255,255); font-size:large;">Donor
> Information</p>
>       <html:errors/><br/>
>       <p>*Indicates required field</p>
> ...
>
> honoree3.jsp page
>
> ...
> <% AllDonationInformationFormBean3 donorBean =
> (AllDonationInformationFormBean3)session.getAttribute("donorBean") ;
>      if(donorBean == null) donorBean = new
> AllDonationInformationFormBean3() ;
>      %>
>
> <html>
>   <head>
>     <meta http-equiv="Content-Type" content="text/html;
> charset=windows-1252">
>     <title>Honor of</title>
>   </head>
>   <body>
>     <center>
>       <h1>In Honor Of</h1>
>     </center>
>     <form action="../donation3/honoree3.do" method="post">
>       <input type="hidden" name="pagename" value="honoreePage"/>
>       <input type="hidden" name="page" value="2"/>
>       <P style="background-color:rgb(0,255,255); font-size:large;">In
> Honor of:</P>
>       <P>*Indicates required field</P>
>       <html:errors/><br/>
> ...
>
>
> On 11/4/06, Christopher Schultz <chris@christopherschultz.net > wrote:
> >
> > -----BEGIN PGP SIGNED MESSAGE-----
> > Hash: SHA1
> >
> > Yariel,
> >
> > > I have a page validated with Validation Framework, but I can get that
> > > page from two diferent jsp inputs. When an error ocurs, the validator
> > > always turn me back to the same jsp input (the one especified) not
> > > matter which was the selected input. It is possible to set two values
> > > to "input" attribute in an ActionMapping?? Is there any other way to
> > > do something like that??
> >
> >
> > Generally, this is done with two separate ActionMappings, like this:
> >
> > <!-- submit to here from first.jsp -->
> > <action path="/path1"
> >     type="MyAction"
> >     name="MyFormBean"
> >     validate="true"
> >     scope="request"
> >     input="/first.jsp">
> >   ...
> > </action>
> >
> > <!-- submit to here from second.jsp -->
> > <action path="/path2"
> >     type="MyAction"
> >     name="MyFormBean"
> >     validate="true"
> >     scope="request"
> >     input="/second.jsp">
> >   ...
> > </action>
> >
> > You are doing the exact same thing in both cases, except that the
> > "input" attributes are different. The validation should be the same,
> > using the same form bean, etc.
> >
> > Hope that helps,
> > - -chris
> > -----BEGIN PGP SIGNATURE-----
> > Version: GnuPG v1.4.5 (MingW32)
> > Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
> >
> > iD8DBQFFTJOE9CaO5/Lv0PARArvPAJ9/6S//E9jkQFVy/QC2mIGUTMBgAACgr4d2
> > NY36tWCeaj9w/2bBwcBpKKY=
> > =CJAz
> > -----END PGP SIGNATURE-----
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > For additional commands, e-mail: user-help@struts.apache.org
> >
> >
>

Re: Two values on "input" attribute

Posted by Thom Burnett <th...@gmail.com>.
I tried this technique for my situation where several jsp pages contribute
to one ActionForm.
I'm getting the correct page selection behavior by my errors don't show up.

For the first page (the donation page) everything works very nicely.
For the second page (the honoree page) there's no trace of an error message.

That is, when (and only when) there's an error, the page will not continue
on to the next page but
the <html:errors/> tag seems to return no contents - that part of the
displayed page is blank.

I can't see any meaningful difference between the two pages. Is this a
question of where the ActionErrors instance is stored?




struts-config
...
    <action path="/donation3"   type="com.softrek.donation.DonationAction3"
            name="donorBean" scope="session"
            input="/donation3.jsp" validate="true">
      <forward name="oracleError"  path="/oracleError3.jsp"/>
      <forward name="success"      path="/thankYou3.jsp"/>
      <forward name="firstPage"    path="/donation3.jsp"/>
      <forward name="secondPage"   path="/honoree3.jsp"/>
      <forward name="thirdPage"    path="/payment3.jsp"/>
    </action>
    <action path="/honoree3"   type="com.softrek.donation.DonationAction3"
            name="donorBean" scope="session"
            input="/honoree3.jsp"  validate="true">
      <forward name="oracleError"  path="/oracleError3.jsp"/>
      <forward name="success"      path="/thankYou3.jsp"/>
      <forward name="firstPage"    path="/donation3.jsp"/>
      <forward name="secondPage"   path="/honoree3.jsp"/>
      <forward name="thirdPage"    path="/payment3.jsp"/>
    </action>
...

donation3.jsp page

...
<% AllDonationInformationFormBean3 donorBean =
(AllDonationInformationFormBean3)session.getAttribute("donorBean") ;
     if(donorBean == null) donorBean = new AllDonationInformationFormBean3()
;
  %>
  <body>
    <center>
      <h1>New Account Registration</h1>
    </center>
    <form action="../donation3/donation3.do" method="post">
      <input type="hidden" name="pagename" value="donationPage"/>
      <input type="hidden" name="page" value="1"/>
      <p style="background-color:rgb(0,255,255); font-size:large;">Donor
Information</p>
      <html:errors/><br/>
      <p>*Indicates required field</p>
...

honoree3.jsp page

...
<% AllDonationInformationFormBean3 donorBean =
(AllDonationInformationFormBean3)session.getAttribute("donorBean") ;
     if(donorBean == null) donorBean = new AllDonationInformationFormBean3()
;
     %>

<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html;
charset=windows-1252">
    <title>Honor of</title>
  </head>
  <body>
    <center>
      <h1>In Honor Of</h1>
    </center>
    <form action="../donation3/honoree3.do" method="post">
      <input type="hidden" name="pagename" value="honoreePage"/>
      <input type="hidden" name="page" value="2"/>
      <P style="background-color:rgb(0,255,255); font-size:large;">In Honor
of:</P>
      <P>*Indicates required field</P>
      <html:errors/><br/>
...


On 11/4/06, Christopher Schultz <ch...@christopherschultz.net> wrote:
>
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Yariel,
>
> > I have a page validated with Validation Framework, but I can get that
> > page from two diferent jsp inputs. When an error ocurs, the validator
> > always turn me back to the same jsp input (the one especified) not
> > matter which was the selected input. It is possible to set two values
> > to "input" attribute in an ActionMapping?? Is there any other way to
> > do something like that??
>
>
> Generally, this is done with two separate ActionMappings, like this:
>
> <!-- submit to here from first.jsp -->
> <action path="/path1"
>     type="MyAction"
>     name="MyFormBean"
>     validate="true"
>     scope="request"
>     input="/first.jsp">
>   ...
> </action>
>
> <!-- submit to here from second.jsp -->
> <action path="/path2"
>     type="MyAction"
>     name="MyFormBean"
>     validate="true"
>     scope="request"
>     input="/second.jsp">
>   ...
> </action>
>
> You are doing the exact same thing in both cases, except that the
> "input" attributes are different. The validation should be the same,
> using the same form bean, etc.
>
> Hope that helps,
> - -chris
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.5 (MingW32)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
>
> iD8DBQFFTJOE9CaO5/Lv0PARArvPAJ9/6S//E9jkQFVy/QC2mIGUTMBgAACgr4d2
> NY36tWCeaj9w/2bBwcBpKKY=
> =CJAz
> -----END PGP SIGNATURE-----
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>

Re: Two values on "input" attribute

Posted by Laurie Harper <la...@holoweb.net>.
Christopher Schultz wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> 
> Yariel,
> 
>> I have a page validated with Validation Framework, but I can get that
>> page from two diferent jsp inputs. When an error ocurs, the validator
>> always turn me back to the same jsp input (the one especified) not
>> matter which was the selected input. It is possible to set two values
>> to "input" attribute in an ActionMapping?? Is there any other way to
>> do something like that??
> 
> 
> Generally, this is done with two separate ActionMappings, like this:
> 
> <!-- submit to here from first.jsp -->
> <action path="/path1"
>     type="MyAction"
>     name="MyFormBean"
>     validate="true"
>     scope="request"
>     input="/first.jsp">
>   ...
> </action>
> 
> <!-- submit to here from second.jsp -->
> <action path="/path2"
>     type="MyAction"
>     name="MyFormBean"
>     validate="true"
>     scope="request"
>     input="/second.jsp">
>   ...
> </action>
> 
> You are doing the exact same thing in both cases, except that the
> "input" attributes are different. The validation should be the same,
> using the same form bean, etc.

Yep; the other option is to set validate to false and call it manually, 
then return the appropriate mapping in your action's execute, but the 
above solution is probably easier.

L.


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


Re: Two values on "input" attribute

Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Yariel,

> I have a page validated with Validation Framework, but I can get that
> page from two diferent jsp inputs. When an error ocurs, the validator
> always turn me back to the same jsp input (the one especified) not
> matter which was the selected input. It is possible to set two values
> to "input" attribute in an ActionMapping?? Is there any other way to
> do something like that??


Generally, this is done with two separate ActionMappings, like this:

<!-- submit to here from first.jsp -->
<action path="/path1"
    type="MyAction"
    name="MyFormBean"
    validate="true"
    scope="request"
    input="/first.jsp">
  ...
</action>

<!-- submit to here from second.jsp -->
<action path="/path2"
    type="MyAction"
    name="MyFormBean"
    validate="true"
    scope="request"
    input="/second.jsp">
  ...
</action>

You are doing the exact same thing in both cases, except that the
"input" attributes are different. The validation should be the same,
using the same form bean, etc.

Hope that helps,
- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFFTJOE9CaO5/Lv0PARArvPAJ9/6S//E9jkQFVy/QC2mIGUTMBgAACgr4d2
NY36tWCeaj9w/2bBwcBpKKY=
=CJAz
-----END PGP SIGNATURE-----

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