You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Siddiq Syed <si...@yahoo.com> on 2009/11/04 22:30:50 UTC

Default mapping to a result.

Hi all,

Once an action method returns a string and if the string is not mapped to a
result name in struts.xml , is there any way where we can display a default
page.

For example as mention in the below struts.xml file,

<action name="determineCaseEvaluationType"
class="com.activity.EvaluateCaseAction"
method="determineCaseEvaluationType">
        	<result name="guidelInitConsid"
type="tiles">editGuidelinesCaseEvaluation</result>
        	<result name="shrtsntcInitConsid"
type="tiles">editShortSentenceCaseEvaluation</result>
        	<result name="sscat2p1InitConsid"
type="tiles">editShortSentenceCaseEvaluation</result>
               <result type="tiles">editGuidelinesCaseEvaluation</result>
 </action>

If the determineCaseEvaluationType() does not return any of the above
mention string , If the method returns any other string ,is there any way
where I can display a default page to the user through tiles.


-- 
View this message in context: http://old.nabble.com/Default-mapping-to-a-result.-tp26204969p26204969.html
Sent from the Struts - User mailing list archive at Nabble.com.


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


Re: Default mapping to a result.

Posted by Dave Newton <ne...@yahoo.com>.
Siddiq Syed wrote:
> If my action return 15 different strings, Do i need to define 15 different reuslt ?

If they're different results, yes--that's the point of results: each is 
a unique result to an action invocation.

> 
> I the below mention scienario my action can return 15 differnet string of which 6 return type string will have different jsp(tiles) and other 9 will have a common jsp to be display.

If you have actions returning different result names that map to the 
same result then there's a design smell--why bother returning different 
strings if they don't change anything?

I'd consider doing one of at least two options:

- Fix the design
- Write a wrapper action method that does the mapping between the 
results that differ and the single result you want

I'd shoot for the first one. Why return different values if the result 
doesn't change?

Dave


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


Re: Default mapping to a result.

Posted by Siddiq Syed <si...@yahoo.com>.
If my action return 15 different strings, Do i need to define 15 different reuslt ?

I the below mention scienario my action can return 15 differnet string of which 6 return type string will have different jsp(tiles) and other 9 will have a common jsp to be display.

If I can reduce the mapping of 9 return values to one , or something  like default or some other attribute that would be great.!!
And everytime if a entry is added in the database or in a propertie file , mapping needs to be change ;-(


Global result is also required to define all the result types !

http://struts.apache.org/2.0.14/docs/result-configuration.html

Thanks
Siddiq.


________________________________
From: Dave Newton <ne...@yahoo.com>
To: Struts Users Mailing List <us...@struts.apache.org>
Sent: Wed, November 4, 2009 11:05:13 PM
Subject: Re: Default mapping to a result.

Siddiq Syed wrote:
> Once an action method returns a string and if the string is not mapped to a
> result name in struts.xml , is there any way where we can display a default
> page.
> 
> For example as mention in the below struts.xml file,
> 
> <action name="determineCaseEvaluationType"
> class="com.activity.EvaluateCaseAction"
> method="determineCaseEvaluationType">
>            <result name="guidelInitConsid"
> type="tiles">editGuidelinesCaseEvaluation</result>
>            <result name="shrtsntcInitConsid"
> type="tiles">editShortSentenceCaseEvaluation</result>
>            <result name="sscat2p1InitConsid"
> type="tiles">editShortSentenceCaseEvaluation</result>
>                <result type="tiles">editGuidelinesCaseEvaluation</result>
>  </action>
> 
> If the determineCaseEvaluationType() does not return any of the above
> mention string , If the method returns any other string ,is there any way
> where I can display a default page to the user through tiles.

You could define global results, available to all action invocations.

IMO returning an unmapped result string is a bug, though.

Dave


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


      

Re: Default mapping to a result.

Posted by Dave Newton <ne...@yahoo.com>.
Siddiq Syed wrote:
> Once an action method returns a string and if the string is not mapped to a
> result name in struts.xml , is there any way where we can display a default
> page.
> 
> For example as mention in the below struts.xml file,
> 
> <action name="determineCaseEvaluationType"
> class="com.activity.EvaluateCaseAction"
> method="determineCaseEvaluationType">
>         	<result name="guidelInitConsid"
> type="tiles">editGuidelinesCaseEvaluation</result>
>         	<result name="shrtsntcInitConsid"
> type="tiles">editShortSentenceCaseEvaluation</result>
>         	<result name="sscat2p1InitConsid"
> type="tiles">editShortSentenceCaseEvaluation</result>
>                <result type="tiles">editGuidelinesCaseEvaluation</result>
>  </action>
> 
> If the determineCaseEvaluationType() does not return any of the above
> mention string , If the method returns any other string ,is there any way
> where I can display a default page to the user through tiles.

You could define global results, available to all action invocations.

IMO returning an unmapped result string is a bug, though.

Dave


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


Re: Default mapping to a result.

Posted by Siddiq Syed <si...@yahoo.com>.
Thanks Greg,

It works, As you said need to add 
<result name="*" type="tiles">editGuidelinesCaseEvaluation</result>

<action name="determineCaseEvaluationType"
class="com.activity.EvaluateCaseAction"
method="determineCaseEvaluationType">
        	<result name="guidelInitConsid"
type="tiles">editGuidelinesCaseEvaluation</result>
        	<result name="shrtsntcInitConsid"
type="tiles">editShortSentenceCaseEvaluation</result>
        	<result name="sscat2p1InitConsid"
type="tiles">editShortSentenceCaseEvaluation</result>
<result name="*" type="tiles">editGuidelinesCaseEvaluation</result>
</action>

If the action return other than the above three values , default (name="*")
will be excuted. !!



Greg Lindholm-2 wrote:
> 
> I've never tried this and haven't found any documentation but reading the
> source it appears you can configure a wildcard result using <result
> name="*">.
> 
> see com.opensymphony.xwork2.DefaultActionInvocation.createResult() source
> [1]
> 
> [1]
> http://svn.opensymphony.com/fisheye/browse/~raw,r=1851/xwork/trunk/src/java/com/opensymphony/xwork2/DefaultActionInvocation.java
> 
> 
> 
> On Wed, Nov 4, 2009 at 4:30 PM, Siddiq Syed <si...@yahoo.com> wrote:
> 
>>
>> Hi all,
>>
>> Once an action method returns a string and if the string is not mapped to
>> a
>> result name in struts.xml , is there any way where we can display a
>> default
>> page.
>>
>> For example as mention in the below struts.xml file,
>>
>> <action name="determineCaseEvaluationType"
>> class="com.activity.EvaluateCaseAction"
>> method="determineCaseEvaluationType">
>>                <result name="guidelInitConsid"
>> type="tiles">editGuidelinesCaseEvaluation</result>
>>                <result name="shrtsntcInitConsid"
>> type="tiles">editShortSentenceCaseEvaluation</result>
>>                <result name="sscat2p1InitConsid"
>> type="tiles">editShortSentenceCaseEvaluation</result>
>>               <result type="tiles">editGuidelinesCaseEvaluation</result>
>>  </action>
>>
>> If the determineCaseEvaluationType() does not return any of the above
>> mention string , If the method returns any other string ,is there any way
>> where I can display a default page to the user through tiles.
>>
>>
>> --
>> View this message in context:
>> http://old.nabble.com/Default-mapping-to-a-result.-tp26204969p26204969.html
>> Sent from the Struts - User mailing list archive at Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>>
>>
> 
> 

-- 
View this message in context: http://old.nabble.com/Default-mapping-to-a-result.-tp26204969p26215736.html
Sent from the Struts - User mailing list archive at Nabble.com.


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


Re: Default mapping to a result.

Posted by Greg Lindholm <gr...@gmail.com>.
I've never tried this and haven't found any documentation but reading the
source it appears you can configure a wildcard result using <result
name="*">.

see com.opensymphony.xwork2.DefaultActionInvocation.createResult() source
[1]

[1]
http://svn.opensymphony.com/fisheye/browse/~raw,r=1851/xwork/trunk/src/java/com/opensymphony/xwork2/DefaultActionInvocation.java



On Wed, Nov 4, 2009 at 4:30 PM, Siddiq Syed <si...@yahoo.com> wrote:

>
> Hi all,
>
> Once an action method returns a string and if the string is not mapped to a
> result name in struts.xml , is there any way where we can display a default
> page.
>
> For example as mention in the below struts.xml file,
>
> <action name="determineCaseEvaluationType"
> class="com.activity.EvaluateCaseAction"
> method="determineCaseEvaluationType">
>                <result name="guidelInitConsid"
> type="tiles">editGuidelinesCaseEvaluation</result>
>                <result name="shrtsntcInitConsid"
> type="tiles">editShortSentenceCaseEvaluation</result>
>                <result name="sscat2p1InitConsid"
> type="tiles">editShortSentenceCaseEvaluation</result>
>               <result type="tiles">editGuidelinesCaseEvaluation</result>
>  </action>
>
> If the determineCaseEvaluationType() does not return any of the above
> mention string , If the method returns any other string ,is there any way
> where I can display a default page to the user through tiles.
>
>
> --
> View this message in context:
> http://old.nabble.com/Default-mapping-to-a-result.-tp26204969p26204969.html
> Sent from the Struts - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>