C
Cowboy Bob
Hi All,
I'm trying to avoid writing a scriptlet but I can't seem to get Struts to
conditionally define a bean. Am I missing something here:-
<logicresent name="<%=Config.KEY%>" scope="session">
<!-- Session Scope -->
<bean:define id="configBean" name="<%=Config.KEY%>" scope="session"/>
</logicresent>
<logic:notPresent name="<%=Config.KEY%>" scope="session">
<!-- Application Scope -->
<bean:define id="configBean" name="<%=Config.KEY%>"
scope="application"/>
</logic:notPresent>
If the bean exists in the user's session, then the "session scope" comment
ends in the page source, but the bean with the id of "configBean" still has
values from the copy in the application scope. Yet in my DynaForm I
definitely have different values for the two scopes.
In case you're wondering, I'm doing an admin interface where the user can
alter the style sheet dynamically. I'm temporarily cloning the Config bean
into the user's session for preview purposes and then using a logic tag to
tell the style.jsp which copy of the bean to use. Or at least that's what
I'm trying to do...
Hope you can help, or it's time for a scriptlet or custom tag. I just
assumed I could do this with the ready-made Struts tags.
Matt
I'm trying to avoid writing a scriptlet but I can't seem to get Struts to
conditionally define a bean. Am I missing something here:-
<logicresent name="<%=Config.KEY%>" scope="session">
<!-- Session Scope -->
<bean:define id="configBean" name="<%=Config.KEY%>" scope="session"/>
</logicresent>
<logic:notPresent name="<%=Config.KEY%>" scope="session">
<!-- Application Scope -->
<bean:define id="configBean" name="<%=Config.KEY%>"
scope="application"/>
</logic:notPresent>
If the bean exists in the user's session, then the "session scope" comment
ends in the page source, but the bean with the id of "configBean" still has
values from the copy in the application scope. Yet in my DynaForm I
definitely have different values for the two scopes.
In case you're wondering, I'm doing an admin interface where the user can
alter the style sheet dynamically. I'm temporarily cloning the Config bean
into the user's session for preview purposes and then using a logic tag to
tell the style.jsp which copy of the bean to use. Or at least that's what
I'm trying to do...
Hope you can help, or it's time for a scriptlet or custom tag. I just
assumed I could do this with the ready-made Struts tags.
Matt