struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Robert Alexandersson" <robert.alexanders...@lorensbergs.com>
Subject RE: Re: Using bean the same way as bundle with a static string as param.
Date Tue, 28 Feb 2006 07:38:48 GMT
Thanx a lot, it worked like a scharm, I just changed the requestScope to
applicationScope.
So I would say u understood!

This works really nice as a rights management replacement.
Would any of you out there implement this different?
I thought of the JSF rendered attribute when I did this.


/Robert

-----Original Message-----
From: news [mailto:news@sea.gmane.org] On Behalf Of Laurie Harper
Sent: Monday, February 27, 2006 9:51 PM
To: user@struts.apache.org
Subject: Re: Using bean the same way as bundle with a static string as
param.

Robert Alexandersson wrote:
> Hello.
> 
> I am using JSP 2.0 tagfiles creating custommtags and want a render
> controller.
> I want to make a sort of <mytag:render property="module.page.part">
> 
> In a controller i create the settingbean parameters.
> In the jsp I call the tag file.
> In the tagfile I try to evaluate the incoming static string byt this I
> can not figure out.
> The render attribute contains a string "render@myapp@person@company"
but
> I can not use this in the test of c:if because it evaluates the string
> not the bean-param value behind it. Is it possible to set this value
> into a new parameter and getting its real value. I can print it using
> bean:write but thats it....
> 
> 
> Example CODE:
> 
> JSP
> <mytag:render property="myapp.person.company">
> 	<fieldset>
> 	      <legend>Company</legend>
> 		<inparam > ...
> 	</fieldset>
> </mytag:render>
> 
> JAVA-CODE
> 
> public static void createRender(ServletContext context){
> context.setAttribute("render@myapp@person@company", new
Boolean(true));
> }
> 
> 
> TAG-FILE
> 
> <%@ tag body-content="scriptless" %>
> <%@ attribute name="property" required="true" %>
> 
> <%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
> <%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
> <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
> 
> <jsp:doBody var="thebody" />
> 
> <c:set var="render" value="render@${fn:replace(property, '.',
> '@')}"></c:set>
> 
> <c:if test="${render}">
> ${thebody}
> </c:if>

I'm not sure I fully understand what you're after, but maybe this will 
do what you want:

   <c:set var="renderExp" value="render@${fn:replace(property, 
'.','@')}"></c:set>
   <c:set var="render" value="${requestScope[renderExp]}"/>

You'll need to change your Java code to store the property in request 
scope instead of the servlet context, too.

L.


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




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


Mime
View raw message