(struts/JSTL) Setting bean property value with jstl choose compoundresults

D

DaFoot

Probably not a very good subject, but best I could come up with!

I have some JSTL in a (struts backed) JSP that creates a statement on
the page like this:

Code:
Some text
	${registrationForm.map.CLI} more text
	<c:choose>
		<c:when test="${registrationForm.map.responseCode eq 'Lin-2a'}">
				at least ${registrationForm.map.displayableMax}.
		</c:when>
		<c:when test="${registrationForm.map.responseCode eq 'Lin-2b'}">
				between ${registrationForm.map.displayableMax} and 8.
		</c:when>
		<c:otherwise>
				up to ${registrationForm.map.displayableMax}.
		</c:otherwise>
	</c:choose>

So I would get something like this in the page:
Some text <form.CLI.value> more text [at least<var>|between<var> and 8|
up to <var>]

I need to find a way to save that entire output string to another
action form property. Simple assignments should be an issue, but I
have no idea how to concat strings into a property using JSTL
(alternatively could use a java scriptlet in the page, but trying to
move away from that approach).

Any suggestions gratefully received.
 
D

DaFoot

DaFoot said:
Probably not a very good subject, but best I could come up with!
I have some JSTL in a (struts backed) JSP that creates a statement on
the page like this:
Code:
Some text
   ${registrationForm.map.CLI} more text
   <c:choose>
           <c:when test="${registrationForm.map.responseCode eq 'Lin-2a'}">
                           at least ${registrationForm.map.displayableMax}.
           </c:when>
           <c:when test="${registrationForm.map.responseCode eq 'Lin-2b'}">
                           between ${registrationForm.map.displayableMax} and 8.
           </c:when>
           <c:otherwise>
                           up to ${registrationForm.map.displayableMax}.
           </c:otherwise>
   </c:choose>
So I would get something like this in the page:
Some text <form.CLI.value> more text [at least<var>|between<var> and 8|
up to <var>]
I need to find a way to save that entire output string to another
action form property. Simple assignments should be an issue, but I
have no idea how to concat strings into a property using JSTL
(alternatively could use a java scriptlet in the page, but trying to
move away from that approach).

Sounds like you are mixing view and logic.  Action forms are supposed to be
about communication of the dynamic data that flows between the user and the
model.  Details of layout and prompt should be the exclusive province of the JSP.

That said, sometimes you have to break the rules, for expediency or other
purpose, and you are willing to pay the technical debt for it.

Keep the entire prompt in the form in the first place, and compute the various
pieces server side.  The same logic that computes
registrationForm.map.displayableMax could also compute the entire string.

Quite right Lew, that is how it *should* be done ;)

Would be awkward to do that because of the flows through the
application. Right now I'm thinking creating a <html:hidden ... >
element inside each choose is the way forward, but environment issues
slowing me down in testing stuff!
 

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

Members online

Forum statistics

Threads
473,743
Messages
2,569,478
Members
44,898
Latest member
BlairH7607

Latest Threads

Top