You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tiles.apache.org by Stetze2008 <st...@gmx.de> on 2008/05/24 12:16:05 UTC

Problem with Struts 2 + Tiles 2 + Validation (result input)

hi,

I'm using Struts 2 and Tiles 2 and have a problem concerning the form 
validation.

If one action throws a validation error (because for example one form 
field is empty) ALL other actions (which are part of the tiles template) 
call the defined tiles definitions for the result "input" and not only 
that action that throws the validation error. therefore my top module 
jumps back to login mode if there is a validation error on the user's 
profile page.

this is my *tiles.xml*:
<definition name="base.definition" template="/layouts/wmBoerseLayout.jsp">
        <put-attribute name="module" value="/menu/module.action"/>
        <put-attribute name="std_menu" value="/common/menu.jsp" />
</definition>

<definition name="page.user.profile" extends="base.definition">
        <put-attribute name="body-content" value="/pages/profile.jsp"/>
</definition>

this is my* struts.xml*:
<action name="module" class="userAction" method="module">
        <interceptor-ref name="myStack"/>
        <result name="user">/modules/user.jsp</result>
        <result name="admin">/modules/admin.jsp</result>
        <result name="login">/modules/login.jsp</result>
        <result name="input">/modules/login.jsp</result>
        <result>/modules/login.jsp</result>
</action>

<action name="editProfile" class="profileAction" method="editProfile">
        <result type="tiles">page.user.profile</result>
        <result name="error" type="tiles">page.user.profile</result>
        <result name="input" type="tiles">page.user.profile</result>
</action>

I would be glad if anyone could help!

Best regards,
Stefan

Re: Problem with Struts 2 + Tiles 2 + Validation (result input)

Posted by Antonio Petrelli <an...@gmail.com>.
2008/5/26 Stetze2008 <st...@gmx.de>:
> I would be glad if somebody of you could give me another hint!

I think you have to ask Struts Users mailing list:
http://struts.apache.org/mail.html

Antonio

Re: Problem with Struts 2 + Tiles 2 + Validation (result input)

Posted by Stetze2008 <st...@gmx.de>.
Antonio Petrelli wrote:
> 2008/5/24 Stetze2008 <st...@gmx.de>:
>   
>>       <result name="error" type="tiles">page.user.profile</result>
>>       <result name="input" type="tiles">page.user.profile</result>
>>     
>
> It seems that you have the same Tiles definition for the "input" and
> the "error" results. Probably you need to define one different
> definition for error.
>
> Antonio
>
>   
Thanks for your reply but defining different tiles definitions for the 
input and error result did not help.
The problem is that if the action editProfile returns a validation error 
it uses the tiles definition page.user.profile defined for the result 
input of this action.

But the definition page.user.profile extends the tiles definition 
base.definition and in this base definition another action 
(/menu/module.action) is called to determine the correct top module to 
be shown. Now it seems that this action is not invoked but also for this 
action the definition defined for the result input is shown (in this 
case the login.jsp what is definitely wrong when the user is logged in)

I would be glad if somebody of you could give me another hint!

tiles.xml:
<definition name="base.definition" template="/layouts/wmBoerseLayout.jsp">
       <put-attribute name="module" value="/menu/module.action"/>
       <put-attribute name="std_menu" value="/common/menu.jsp" />
</definition>

<definition name="page.user.profile" extends="base.definition">
       <put-attribute name="body-content" value="/pages/profile.jsp"/>
</definition>

struts.xml:
<action name="module" class="userAction" method="module">
       <interceptor-ref name="myStack"/>
       <result name="user">/modules/user.jsp</result>
       <result name="admin">/modules/admin.jsp</result>
       <result name="login">/modules/login.jsp</result>
       <result name="input">/modules/login.jsp</result>
       <result>/modules/login.jsp</result>
</action>

<action name="editProfile" class="profileAction" method="editProfile">
       <result type="tiles">page.user.profile</result>
       <result name="error" type="tiles">page.user.profile</result>
       <result name="input" type="tiles">page.user.profile</result>
</action>

Re: Problem with Struts 2 + Tiles 2 + Validation (result input)

Posted by Antonio Petrelli <an...@gmail.com>.
2008/5/24 Stetze2008 <st...@gmx.de>:
>       <result name="error" type="tiles">page.user.profile</result>
>       <result name="input" type="tiles">page.user.profile</result>

It seems that you have the same Tiles definition for the "input" and
the "error" results. Probably you need to define one different
definition for error.

Antonio