Conditional Bean:Define Statements In Struts

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:-

<logic:present name="<%=Config.KEY%>" scope="session">
<!-- Session Scope -->
<bean:define id="configBean" name="<%=Config.KEY%>" scope="session"/>
</logic:present>

<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
 
M

Matt Parker

Cowboy said:
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:-
<snip>

I am, and I'm an idiot...

Matt
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top