Well, I think the reason was my lack of jsp experience...

2009/2/19 Tim Fennell <[email protected]>:
> Is there a reason that you can't do something like (syntax may be
> slightly off):
>
>        <s:url var="myUrl" beanclass="com.foo.bar.ActionBean"/>
>        <jsp:redirect url="${myUrl}"/>
>
> -t
> On Feb 19, 2009, at 5:26 AM, Richard Hauswald wrote:
>
>> Hello,
>> i want to send a redirect to a stripes action bean inside a jsp page
>> referencing the bean by its class name, not the url. I looked up the
>> source code of stripes and created Class with a static function in it,
>> doing the translation:
>>
>> public static String buildUrl(ServletRequest request, ServletResponse
>> response, String nameOrClass) throws StripesJspException {
>>               return buildUrl(request, response, nameOrClass, null);
>> }
>> public static String buildUrl(ServletRequest request, ServletResponse
>> response, String nameOrClass, String event)
>>                       throws StripesJspException {
>>               // Add all the parameters and reset the href attribute; pass to
>> false
>>               // here because
>>               // the HtmlTagSupport will HtmlEncode the ampersands for us
>>               String base = getUrlBinding(nameOrClass);
>>               if (base == null || base.length() < 1)
>>                       return MessageFormat.format("class {0} not found", 
>> nameOrClass);
>>               UrlBuilder builder = new UrlBuilder(
>>                               request.getLocale(),
>>                               base,
>>                               false);
>>               if (event != null) {
>>                       builder.setEvent(event);
>>               }
>>
>>               // Prepend the context path, but only if the user didn't 
>> already
>>               String url = builder.toString();
>>               String contextPath = ((HttpServletRequest)
>> request).getContextPath();
>>               if (contextPath.length() > 1 && !url.startsWith(contextPath + 
>> '/'))
>>                       url = contextPath + url;
>>
>>               return ((HttpServletResponse) response).encodeURL(url);
>> }
>> Now I can do the folowing in my jsp:
>> <%
>>       response.sendRedirect(StripesLinkHelper.buildUrl(request, response,
>>                       "de.dser.dwh.fe.controller.impl.app."));
>> %>
>>
>> I know that this is ugly and dirty, thatswhy I'm interested in a more
>> beautiful solution.
>> Thanks in advance,
>> Richard
>>
>> ------------------------------------------------------------------------------
>> Open Source Business Conference (OSBC), March 24-25, 2009, San
>> Francisco, CA
>> -OSBC tackles the biggest issue in open source: Open Sourcing the
>> Enterprise
>> -Strategies to boost innovation and cut costs with open source
>> participation
>> -Receive a $600 discount off the registration fee with the source
>> code: SFAD
>> http://p.sf.net/sfu/XcvMzF8H
>> _______________________________________________
>> Stripes-users mailing list
>> [email protected]
>> https://lists.sourceforge.net/lists/listinfo/stripes-users
>
>
> ------------------------------------------------------------------------------
> Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
> -OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
> -Strategies to boost innovation and cut costs with open source participation
> -Receive a $600 discount off the registration fee with the source code: SFAD
> http://p.sf.net/sfu/XcvMzF8H
> _______________________________________________
> Stripes-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/stripes-users
>

------------------------------------------------------------------------------
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
_______________________________________________
Stripes-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/stripes-users

Reply via email to