Re: [Stripes-users] the Stripes & my small problems ...

Subject:   Re: [Stripes-users] the Stripes & my small problems ... (find more)
From:   Tim Fennell <hidden> (find more)
Date:   Jan 18, 2006 22:31

Hi,

Sorry for the latency on the reply.

>
> The first problem is <stripes:link ....
> I have following situation :
> <stripes:link href="javascript:{popUp('?idxAdd=x');}" ...
> or
> <stripes:link href="#" onclick="popUp('?idxEdit=${loop.index}');"
> ,the Stripes' tag 'link' generate wrong URL in HTML. http://
> localhost:8080/assjavascript:%7BpopUp('?idxAdd=x');}&_sourcePage=%
> 2Fzone%2Fapplications%2FapplicationList.jsp
> and
> http://localhost:8080/ass#?_sourcePage=%2Fzone%2Fapplications%
> 2FapplicationList.jsp
I think the correct solution to this problem is probably just to use  
a regular HTML <a href="#" onclick=""/>.  The stripes:link tag is  
really only intended for generating links that directly submit to a  
Stripes action.  If you just want a link that executes some  
Javascript there is absolutely nothing wrong with using a regular <a  
href...> tag.  Does this not work for you for some reason?


>     ... other problem with stripes:link tag ... I needed the  
> 'title' – attribute in the tag, contain text from Reources file  
> like 'titleKey' – attribute in the struts tag, and use multi-
> language support. I made some changes in classes
> LinkTag.java - http://z-builder.dir.bg/_files/27968.java
> HtmlTagSupport.java - http://z-builder.dir.bg/_files/27969.java
> and
> stripes.tld. - http://z-builder.dir.bg/_files/27985.tld
> I added in the new attribute 'titleKey' that replace 'title'  
> attribute with text from Resources file if it's present.
I can see how this might be useful.  The standard solution up until  
now (and this will answer your next question also) has been to do  
something like this:
 <fmt:message var="title" "my.title.key"/>  <!-- maybe also supply  
bundle="StripesResources" if it's not setup elsewhere for JSTL -->
         <stripes:link href="/foo.action" title="${title}"/>

Stripes has been designed to interoperate with the JSTL and as a  
result I have tried hard not to build things that are already  
available through JSTL.  I've also been striving to keep the HTML-
analog tags as close to their HTML equivalents as possible.  Still,  
please log a JIRA bug for this at http://mc4j.org/jira/browse/STS

>     ... I don't see alternative of struts <bean:message> tag ... I  
> see <stripes:label> , but it generate resource text in the <label>  
> tag ... I use <stripes:link> tag out of <form ... > for ex. In  
> 'navigation' :
> <stripes:link ...><stripes:label ... ></ stripes:link>, that  
> generate <a ...><label>...</label></a> ...
>
>     ... I don't need from ... <label>...</label> ...
> and my question :
> --- How I can get text-resource from resources file in the JSP file  
> (cleanly) ?
The best approach here is to use the JSTL tags.  <fmt:message> is a  
close approxmation to the Struts <bean:message> tag.

>     ... and the last question :
> --- What is the cleanly way to get data from one ActionBean(1) in  
> other ActionBean(2) , if ActionBean(1) have @SessionScope Annotation?
> (I made some gymnastics ... to resolve it, but I don't sure that is  
> the right-way...)
If you just want to grab a reference to a bean that you know is  
session scoped then the easiest way to do it is to use the  
ActionResolver to fetch it for you.  This can be done as follows  
(assuming this code is in Bean2:

StripesFilter.getConfiguration().getActionResolver().getActionBean
( getContext(), "/binding/for/bean1");
// or
StripesFilter.getConfiguration().getActionResolver().getActionBean
( getContext(), Bean1.class.getAnnotation(UrlBinding.class).value());

While the second approach is a few more characters it does ensure  
that you don't end up retying the URL binding for Bean1 everywhere!

I hope that all helps.  If anything isn't clear, or  you have more  
questions, fire away!

-t


Entire Thread (Showing 3 of 3)