Thank you for your post and for your possible solutions. But I found another
way for using forwards to action. Just put the following lines in your
web.xml  and all works well:

<filter-mapping>
        <filter-name>struts</filter-name>
        <url-pattern>/*</url-pattern>
        <dispatcher>REQUEST</dispatcher> 
        <dispatcher>FORWARD</dispatcher>
</filter-mapping>

By default only requests are allowed but no forwards!


dusty wrote:
> 
> First of all this is the third time I have tried to respond as I keep
> trying to use ctrl+W to select a word while editing in this text area and
> closing the browser tab.  (IDEA muscle memory).
> 
> Ok, so my first question is why have a Search action and then a separate
> SearchResults action?  What does SearchResults do that Search does not do
> or vice versa?  I would expect you would just submit the form to an action
> called Search, find stuff there and then dispatch to a results page from
> there.  Your form can do a GET rather than POST and that will make things
> like the back button and refresh work better.  Especially since
> technically you are not changing state a GET is appropriate.
> 
> There may be a few things you can do:
> 
> #1 - Show the user the search results with the error, asking them to try
> again.
> Dispatch to the search results page:
> <action name="search" class="com.foo.SearchAction">
>    <result type="tiles">searchResultPage</result>  
>    <result name="input" type="tiles">searchResultPage</result> 
>    <result name="error" type="tiles">searchResultPage</result>
> </action> 
> 
> #2 - Use the MessageStoreInterceptor and a querystring param to redirect
> to the original action
> With the MessageStoreInterceptor actionMessages, actionErrors and
> fieldErrors will be available after the redirect.  Include a request param
> with the offending value and have your original action look for that to
> populate the search form.  For anything to survive a redirect it has to go
> in the session (MessageStore) or be part of the redirect url.
> <action name="search" class="com.foo.SearchAction">
>    <result type="tiles">searchResultPage</result>  
>    <result name="input"
> type="redirect">${originalAction}?query=${query}</result> 
>    <result name="error"
> type="redirect">${originalAction}?query=${query}</result> 
> </action> 
> 
> 
> #3 - Remove the validation/workflow interceptors from the Search action
> and hand validate the value in your Search action method.  If there is an
> error then return a String for the tiles result you want.
> This is not my favorite option
> <action name="search" class="com.foo.SearchAction">
>    <result type="tiles">searchResultPage</result>  
>    <result name="welcome" type="tiles">welcomePage</result>
>    <result name="product" type="tiles">productPage</result>
>    etc...
> </action> 
> 
> I think you are correct that this is a common pattern.  When I have
> implemented a QuickSearch in the global nav, I use option #1 and display
> any errors or results on a results page.  I think what makes your pattern
> unique is that you want to display the error in the original page.  
> 
> p.s.  I am tiles ignorant so I am treating them like they were a JSP page
> since they seem to both use the dispatch result type.  (woot SiteMesh!)
> 
> 
> Dirk Forchel wrote:
>> 
>> I could not resolve my problem yet. How can I use the "dispatch" result
>> type to forward to actions (or maybe tiles definitions) rather than to
>> JSPs?
>> In my application are some situations where I have to forward the error
>> messages or the field validation errors to to a different action. I can
>> not use JSPs cos we use Tiles.
>> Let's assume we have four different Pages. A welcome-page displaying some
>> welcome information and a "search-form", a category-page displaying a
>> list of products and the same "search-form", a product page displaying
>> detailed product information and the same "search-form" and a
>> "search-result-page" displaying a list of products and as well the same
>> "search-form".
>> This is the struts config how it could look like:
>> 
>> <action name="welcome">
>>   <result type="tiles">welcomePage</result>
>> </action>
>> 
>> <action name="category" class="com.foo.CategoryAction">
>>   <result type="tiles">categoryPage</result>
>> </action>
>> 
>> <action name="product" class="com.foo.ProductAction">
>>   <result type="tiles">productPage</result>
>> </action>
>>                
>> <action name="search" class="com.foo.SearchAction">
>>    <result type="redirect-action">searchResult</result>                      
>>    <result name="input" type="dispatch">sameAction</result> 
>>    <result name="error" type="dispatch">sameAction</result>
>> </action>
>> 
>> <action name="searchResult" class="com.foo.SearchListAction">
>>   <result type="tiles">searchResultPage</result>
>> </action>
>> 
>> I do not display the tiles definition here. But it is important to me to
>> have a "forward" to an action defintion rather than a "redirect". Once I
>> redirect, I'm going to lose request-scoped data. "redirect" to actions
>> works perfectly but "forward" doesn't. In my struts configuration
>> sameAction should be dynamically substituted with the action name or the
>> action call where the form is included, either "/welcome.action",
>> "/product.action", "/category.action" or even "/searchResult.action".
>> Has somebody any idea how to accomplish this? I reckon this is a almost
>> common workflow.
>> 
> 
> 

-- 
View this message in context: 
http://www.nabble.com/-S2--Result-Type-Dispatch-problem-with-relative-Action-calls-tp21368053p21474858.html
Sent from the Struts - User mailing list archive at Nabble.com.


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

Reply via email to