You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by st...@gmail.com on 2007/05/02 20:13:40 UTC

How to avoid hard coding input result

How do I get the Action input to return to *the* page that failed the
validation?  It could be addPage, UpdatePage, or deletePage.

<result name="input"
            type="tiles">
            *_tileThatFailedValidation_*
</result>

-- 
Scott
stanlick@gmail.com

Re: How to avoid hard coding input result

Posted by st...@gmail.com.
Thanks brother!  Is this "old school" technique still used in S2?  I would
have guessed S2 would hold on to previous request information in the
ActionContext so developers would no longer have to do this riff raff.

On 5/2/07, Musachy Barroso <mu...@gmail.com> wrote:
>
> Struts never knows what is *the page* that failed. The action gets an http
> request, but it doesn't know what was the page, with the submit in it,
> that
> caused the request. You can pass a hidden field with the name of the
> page(let's say "inputPage"), and then have a result like this:
>
> <result name="input"
>            type="tiles">
>            ${#parameters.inputPage}
> </result>
>
> musachy
>
> On 5/2/07, stanlick@gmail.com <st...@gmail.com> wrote:
> >
> > How do I get the Action input to return to *the* page that failed the
> > validation?  It could be addPage, UpdatePage, or deletePage.
> >
> > <result name="input"
> >             type="tiles">
> >             *_tileThatFailedValidation_*
> > </result>
> >
> > --
> > Scott
> > stanlick@gmail.com
> >
>
>
>
> --
> "Hey you! Would you help me to carry the stone?" Pink Floyd
>



-- 
Scott
stanlick@gmail.com

Re: How to avoid hard coding input result

Posted by st...@gmail.com.
I was including the hidden fields in the base.jsp that all my tiles extend.
The reason the

result name="input"     type="tiles">${#parameters.tile}</result>

was not being populated is because the hidden fields were NOT in the
specific form that was being POST'ed.  In order for this to work, developers
would have to *remember* to add these hidden fields to all their page
forms!  Gross!!!  Is there a better way to do this?  The hidden fields are
in the HTML, just not part of the request.  Can they be fished from the
ValueStack some other way?

Better yet, is the org.apache.struts2.tiles.StrutsTilesListener stashing the
tiles definition someplace?  This seems like a framework issue relating to
restoring target result if validation fails.

Scott

On 5/2/07, Musachy Barroso <mu...@gmail.com> wrote:
>
> I'm not sure what that error is, but you can use OGNL expression on
> results,
> using ${expression}, and the request parameters are available in
> #parameters, so yes, it should work :)
>
> musachy
>
> On 5/2/07, stanlick@gmail.com <st...@gmail.com> wrote:
> >
> > Are you sure about this technique?  I have the hidden field in my page
> and
> > I
> > can see that it is set to the correct string, however, when this page is
> > POSTed, I get the following error.  It appears that the hidden field is
> > not
> > quite making it into the struts.xml result.
> >
> >
> > 15:04:38,762  WARN org.apache.tiles.impl.BasicTilesContainer.render:368
> -
> > Unable to find the definition ''
> > May 2, 2007 3:04:38 PM
> org.apache.catalina.core.StandardWrapperValveinvoke
> > SEVERE: Servlet.service() for servlet default threw exception
> > org.apache.tiles.definition.NoSuchDefinitionException:
> >
> > On 5/2/07, Musachy Barroso <mu...@gmail.com> wrote:
> > >
> > > Struts never knows what is *the page* that failed. The action gets an
> > http
> > > request, but it doesn't know what was the page, with the submit in it,
> > > that
> > > caused the request. You can pass a hidden field with the name of the
> > > page(let's say "inputPage"), and then have a result like this:
> > >
> > > <result name="input"
> > >            type="tiles">
> > >            ${#parameters.inputPage}
> > > </result>
> > >
> > > musachy
> > >
> > > On 5/2/07, stanlick@gmail.com <st...@gmail.com> wrote:
> > > >
> > > > How do I get the Action input to return to *the* page that failed
> the
> > > > validation?  It could be addPage, UpdatePage, or deletePage.
> > > >
> > > > <result name="input"
> > > >             type="tiles">
> > > >             *_tileThatFailedValidation_*
> > > > </result>
> > > >
> > > > --
> > > > Scott
> > > > stanlick@gmail.com
> > > >
> > >
> > >
> > >
> > > --
> > > "Hey you! Would you help me to carry the stone?" Pink Floyd
> > >
> >
> >
> >
> > --
> > Scott
> > stanlick@gmail.com
> >
>
>
>
> --
> "Hey you! Would you help me to carry the stone?" Pink Floyd
>



-- 
Scott
stanlick@gmail.com

Re: How to avoid hard coding input result

Posted by Musachy Barroso <mu...@gmail.com>.
I'm not sure what that error is, but you can use OGNL expression on results,
using ${expression}, and the request parameters are available in
#parameters, so yes, it should work :)

musachy

On 5/2/07, stanlick@gmail.com <st...@gmail.com> wrote:
>
> Are you sure about this technique?  I have the hidden field in my page and
> I
> can see that it is set to the correct string, however, when this page is
> POSTed, I get the following error.  It appears that the hidden field is
> not
> quite making it into the struts.xml result.
>
>
> 15:04:38,762  WARN org.apache.tiles.impl.BasicTilesContainer.render:368 -
> Unable to find the definition ''
> May 2, 2007 3:04:38 PM org.apache.catalina.core.StandardWrapperValveinvoke
> SEVERE: Servlet.service() for servlet default threw exception
> org.apache.tiles.definition.NoSuchDefinitionException:
>
> On 5/2/07, Musachy Barroso <mu...@gmail.com> wrote:
> >
> > Struts never knows what is *the page* that failed. The action gets an
> http
> > request, but it doesn't know what was the page, with the submit in it,
> > that
> > caused the request. You can pass a hidden field with the name of the
> > page(let's say "inputPage"), and then have a result like this:
> >
> > <result name="input"
> >            type="tiles">
> >            ${#parameters.inputPage}
> > </result>
> >
> > musachy
> >
> > On 5/2/07, stanlick@gmail.com <st...@gmail.com> wrote:
> > >
> > > How do I get the Action input to return to *the* page that failed the
> > > validation?  It could be addPage, UpdatePage, or deletePage.
> > >
> > > <result name="input"
> > >             type="tiles">
> > >             *_tileThatFailedValidation_*
> > > </result>
> > >
> > > --
> > > Scott
> > > stanlick@gmail.com
> > >
> >
> >
> >
> > --
> > "Hey you! Would you help me to carry the stone?" Pink Floyd
> >
>
>
>
> --
> Scott
> stanlick@gmail.com
>



-- 
"Hey you! Would you help me to carry the stone?" Pink Floyd

Re: How to avoid hard coding input result

Posted by st...@gmail.com.
Are you sure about this technique?  I have the hidden field in my page and I
can see that it is set to the correct string, however, when this page is
POSTed, I get the following error.  It appears that the hidden field is not
quite making it into the struts.xml result.


15:04:38,762  WARN org.apache.tiles.impl.BasicTilesContainer.render:368 -
Unable to find the definition ''
May 2, 2007 3:04:38 PM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet default threw exception
org.apache.tiles.definition.NoSuchDefinitionException:

On 5/2/07, Musachy Barroso <mu...@gmail.com> wrote:
>
> Struts never knows what is *the page* that failed. The action gets an http
> request, but it doesn't know what was the page, with the submit in it,
> that
> caused the request. You can pass a hidden field with the name of the
> page(let's say "inputPage"), and then have a result like this:
>
> <result name="input"
>            type="tiles">
>            ${#parameters.inputPage}
> </result>
>
> musachy
>
> On 5/2/07, stanlick@gmail.com <st...@gmail.com> wrote:
> >
> > How do I get the Action input to return to *the* page that failed the
> > validation?  It could be addPage, UpdatePage, or deletePage.
> >
> > <result name="input"
> >             type="tiles">
> >             *_tileThatFailedValidation_*
> > </result>
> >
> > --
> > Scott
> > stanlick@gmail.com
> >
>
>
>
> --
> "Hey you! Would you help me to carry the stone?" Pink Floyd
>



-- 
Scott
stanlick@gmail.com

Re: How to avoid hard coding input result

Posted by st...@gmail.com.
Is there a "soft" way to get the name of the tile definition into this
hidden field without hard coding it someplace?  I really dislike coding
names and places beyond the XML file itself.  I already have a BaseAction
that extends ActionSupport that is starting to make me ill!  I really would
have guessed that S2 would have offered a way to *discover* where control
should return in the event of validation failure.  Right now, my BaseAction
property is not even helping since the Action is being replaced on each
request!!!

On 5/2/07, Musachy Barroso <mu...@gmail.com> wrote:
>
> Struts never knows what is *the page* that failed. The action gets an http
> request, but it doesn't know what was the page, with the submit in it,
> that
> caused the request. You can pass a hidden field with the name of the
> page(let's say "inputPage"), and then have a result like this:
>
> <result name="input"
>            type="tiles">
>            ${#parameters.inputPage}
> </result>
>
> musachy
>
> On 5/2/07, stanlick@gmail.com <st...@gmail.com> wrote:
> >
> > How do I get the Action input to return to *the* page that failed the
> > validation?  It could be addPage, UpdatePage, or deletePage.
> >
> > <result name="input"
> >             type="tiles">
> >             *_tileThatFailedValidation_*
> > </result>
> >
> > --
> > Scott
> > stanlick@gmail.com
> >
>
>
>
> --
> "Hey you! Would you help me to carry the stone?" Pink Floyd
>



-- 
Scott
stanlick@gmail.com

Re: How to avoid hard coding input result

Posted by Musachy Barroso <mu...@gmail.com>.
Struts never knows what is *the page* that failed. The action gets an http
request, but it doesn't know what was the page, with the submit in it, that
caused the request. You can pass a hidden field with the name of the
page(let's say "inputPage"), and then have a result like this:

<result name="input"
           type="tiles">
           ${#parameters.inputPage}
</result>

musachy

On 5/2/07, stanlick@gmail.com <st...@gmail.com> wrote:
>
> How do I get the Action input to return to *the* page that failed the
> validation?  It could be addPage, UpdatePage, or deletePage.
>
> <result name="input"
>             type="tiles">
>             *_tileThatFailedValidation_*
> </result>
>
> --
> Scott
> stanlick@gmail.com
>



-- 
"Hey you! Would you help me to carry the stone?" Pink Floyd