Thanks to your help, both of you. I'll figure your proposals out after
Christmas.


Nils-Helge Garli wrote:
> 
> I know that it is not recommended, but since you couldn't get it
> working the other way, I figured that was the closest out of the box
> use case that could work. The proposed dispatcher values did work for
> me. At least the action was found. Got some other problems, but don't
> know if it's related. Have you looked into redirecting and using the
> MessageStoreInterceptor [1]?
> 
> Nils-H
> 
> [1] - http://struts.apache.org/2.0.14/docs/message-store-interceptor.html
> 
> On Fri, Dec 19, 2008 at 9:04 PM, Dirk Forchel <dirk.forc...@exedio.com>
> wrote:
>>
>> This result type invokes an entire other action, complete with it's own
>> interceptor stack and result. As you can read here
>> (http://struts.apache.org/2.x/docs/action-chaining.html), it is not
>> recommended. I need the dispatcher result to forward to another action
>> with
>> the same interceptor stack (if validation fails, the error message or
>> field
>> error message is important to mee and to the user as well). I don't
>> understand why this quite common task isn't possible in Struts 2. I did
>> this
>> all the time with Struts 1. Any other idea how to solve my problem???
>>
>>
>> Nils-Helge Garli wrote:
>>>
>>> In that case, I'm out of ideas. If referrer always is an action, have
>>> you tried using the chain result type instead? Probably needs a bit
>>> more parsing of the action and namespace (or look it up from the
>>> action invocation) though.
>>>
>>> Nils-H
>>>
>>> On Fri, Dec 19, 2008 at 11:59 AM, Dirk Forchel <dirk.forc...@exedio.com>
>>> wrote:
>>>>
>>>> Good guess. I've added both attributes to my web.xml. But it doesn't
>>>> work
>>>> either. If the context path (Tomcat server.xml) of my webapp is "" the
>>>> result is
>>>>
>>>> HTTP Status 404 - /welcome.action
>>>> type Status report
>>>> message /welcome.action
>>>> description The requested resource (/welcome.action) is not available.
>>>>
>>>> If I change the context path to "/" in my server.xml the result is:
>>>>
>>>> HTTP Status 404 - //welcome.action
>>>> type Status report
>>>> message //welcome.action
>>>> description The requested resource (//welcome.action) is not available.
>>>>
>>>> If I would change the context path to "/demo", the error would be:
>>>>
>>>> HTTP Status 404 - /demo/welcome.action
>>>> type Status report
>>>> message /demo/welcome.action
>>>> description The requested resource (/demo/welcome.action) is not
>>>> available.
>>>>
>>>> Any other idea what's going on here? Maybe something with the
>>>> RequestDispatcher class?
>>>>
>>>>
>>>> Nils-Helge Garli wrote:
>>>>>
>>>>> I think the error is in your web.xml. Try adding
>>>>>
>>>>> <dispatcher>REQUEST</dispatcher>
>>>>> <dispatcher>FORWARD</dispatcher>
>>>>>
>>>>> in the filter mapping configuration for the struts 2 filter.
>>>>>
>>>>> Nils-H
>>>>>
>>>>> On Fri, Dec 19, 2008 at 10:38 AM, Dirk Forchel
>>>>> <dirk.forc...@exedio.com>
>>>>> wrote:
>>>>>>
>>>>>> Here is my riddle: Why does a dispatch forward to an absolute
>>>>>> URL-path
>>>>>> e.g.
>>>>>> "http://localhost:9001/welcome.action"; not work. Using a relative URL
>>>>>> like
>>>>>> "/welcome.action" doesn't work either. Only something dispatch
>>>>>> forwards
>>>>>> like
>>>>>> "/jsp/pages/welcome.jsp" or similiar (a relative URL with a JSP
>>>>>> resource)
>>>>>> works for me.
>>>>>> But I wanna use Tiles and therefore a forward to an "Action" rather
>>>>>> than
>>>>>> a
>>>>>> JSP. I have a search form included in various and different pages
>>>>>> (different
>>>>>> JSPs and Tiles-definitions). If input validation fails on my search
>>>>>> action,
>>>>>> the field error should be displayed on the same page the input error
>>>>>> occured.
>>>>>> The seach form is used on almost every page of my web application.
>>>>>> This problem drives me almost insane!!!
>>>>>> Everyone can test it by yourself.
>>>>>> Here is my Test-Configuration (without Tiles) and almost the complete
>>>>>> code:
>>>>>>
>>>>>>
>>>>>> struts.xml:
>>>>>>
>>>>>> <struts>
>>>>>>   <package name="demostore" extends="struts-default">
>>>>>>      <default-interceptor-ref name="paramsPrepareParamsStack"/>
>>>>>>
>>>>>>      <default-action-ref name="welcome"/>
>>>>>>
>>>>>>      <global-results>
>>>>>>         <result name="input">${referer}</result>
>>>>>>      </global-results>
>>>>>>
>>>>>>      <action name="search" class="com.foo.SearchAction">
>>>>>>         <result>/jsp/pages/search.result.jsp</result>
>>>>>>      </action>
>>>>>>
>>>>>>      <action name="*" class="com.foo.action.ForwardAction">
>>>>>>         <result>/jsp/pages/{1}.jsp</result>
>>>>>>      </action>
>>>>>>   </package>
>>>>>> </struts>
>>>>>>
>>>>>>
>>>>>> BaseAction.java:
>>>>>>
>>>>>> public class BaseAction extends ActionSupport implements
>>>>>> ServletRequestAware, Preparable
>>>>>> {
>>>>>>   private String referer;
>>>>>>   protected HttpServletRequest request;
>>>>>>
>>>>>>   @Override
>>>>>>   public void setServletRequest(HttpServletRequest request)
>>>>>>   {
>>>>>>      this.request = request;
>>>>>>   }
>>>>>>
>>>>>>   @Override
>>>>>>   public void prepare() throws Exception
>>>>>>   {
>>>>>>      referer = request.getHeader( "Referer" );
>>>>>>      if (referer==null)
>>>>>>         referer = request.getContextPath();
>>>>>>   }
>>>>>>
>>>>>>   public String getReferer()
>>>>>>   {
>>>>>>      // THIS WORKS
>>>>>>      // return "/jsp/pages/welcome.jsp";
>>>>>>      // THIS DOES'NT WORK
>>>>>>      // return "/welcome.action";
>>>>>>      // THIS DOESN'T WORK EITHER
>>>>>>      return referer;
>>>>>>   }
>>>>>> }
>>>>>>
>>>>>> ForwardAction.java:
>>>>>>
>>>>>> public class ForwardAction extends BaseAction
>>>>>> {
>>>>>>     public String execute() throws Exception
>>>>>>     {
>>>>>>        addToHistory(getServletRequest());
>>>>>>        return executeInternal();
>>>>>>     }
>>>>>>
>>>>>>     protected void addToHistory(HttpServletRequest request)
>>>>>>     {
>>>>>>         // Request History
>>>>>>         // History.addEntry(request);
>>>>>>     }
>>>>>>
>>>>>>     protected String executeInternal() throws Exception
>>>>>>     {
>>>>>>         // forward actios should overwrite this method and do some
>>>>>> additional work
>>>>>>         return SUCCESS;
>>>>>>     }
>>>>>> }
>>>>>>
>>>>>> SearchAction.java:
>>>>>>
>>>>>> public class SearchAction extends BaseAction
>>>>>> {
>>>>>>   private String searchString;
>>>>>>
>>>>>>   public String execute() throws Exception
>>>>>>   {
>>>>>>      // DO SOME SEARCH
>>>>>>      return SUCCESS;
>>>>>>   }
>>>>>>
>>>>>>   public void setSearchString(String searchString)
>>>>>>   {
>>>>>>      this.searchString = searchString;
>>>>>>   }
>>>>>>
>>>>>>   public String getSearchString()
>>>>>>   {
>>>>>>      return searchString;
>>>>>>   }
>>>>>> }
>>>>>>
>>>>>> welcome.jsp:
>>>>>>
>>>>>> ...
>>>>>> <html>
>>>>>>   <head>
>>>>>>      <title>Welcome</title>
>>>>>>   </head>
>>>>>>   <body>
>>>>>>      Welcome
>>>>>>      <s:include value="form.search.jsp" />
>>>>>>   </body>
>>>>>> </html>
>>>>>>
>>>>>> form.search.jsp:
>>>>>>
>>>>>> ...
>>>>>> <s:form action="search">
>>>>>>   <label for="searchString">
>>>>>>      <s:text name="search.term"/>
>>>>>>   </label>
>>>>>>   <s:textfield name="searchString" />
>>>>>>   <s:submit key="search.submit" />
>>>>>> </s:form>
>>>>>>
>>>>>> SearchAction-validation.xml:
>>>>>> ...
>>>>>> <validators>
>>>>>>   <field name="searchString">
>>>>>>      <field-validator type="requiredstring">
>>>>>>         <message key="error.searchstring.required"/>
>>>>>>      </field-validator>
>>>>>>   </field>
>>>>>> </validators>
>>>>>>
>>>>>> That's it. So where is the error?
>>>>>>
>>>>>> --
>>>>>> View this message in context:
>>>>>> http://www.nabble.com/Christmas-Riddle-tp21088385p21088385.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
>>>>>>
>>>>>>
>>>>>
>>>>> ---------------------------------------------------------------------
>>>>> To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
>>>>> For additional commands, e-mail: user-h...@struts.apache.org
>>>>>
>>>>>
>>>>>
>>>>
>>>> --
>>>> View this message in context:
>>>> http://www.nabble.com/Christmas-Riddle-tp21088385p21089437.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
>>>>
>>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
>>> For additional commands, e-mail: user-h...@struts.apache.org
>>>
>>>
>>>
>>
>> --
>> View this message in context:
>> http://www.nabble.com/Christmas-Riddle-tp21088385p21097555.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
>>
>>
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
> For additional commands, e-mail: user-h...@struts.apache.org
> 
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Christmas-Riddle-tp21088385p21114334.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