If you want to use a Constants class to use within JSTL syntax, here are the basic rules:

1: Constants has to be a true Bean.
-- it must have a public constructor that takes no parameters (public Constants())


2: The "fields you want to access must also be true Bean fields:
ie:
private Static CONSTANT_KEY_1 = "a_constant_key"; // perhaps used by your code elsewhere
public String getConstantKey() { return CONSTANT_KEY; }



3: In your .jsp: <jsp:useBean class="Constants" id="constants"> <c:out value="${constants.constantKey}" />

hth.

--adam

From: Mike Duffy <[EMAIL PROTECTED]>
Reply-To: "Struts Users Mailing List" <[EMAIL PROTECTED]>
To: Struts Users Mailing List <[EMAIL PROTECTED]>
Subject: paramId in html-el:link tag - Referenceing a Constant
Date: Sun, 20 Jul 2003 14:43:25 -0700 (PDT)

The "struts-example\registration.jsp" contains the following code:

<html:link page="/editSubscription.do?action=Create" paramId="username"
 paramName="registrationForm" paramProperty="username">
  <bean:message key="registration.addSubscription"/>
</html:link>

Switching this to an html-el:link tag is easy.

<html-el:link page="/editSubscription.do?action=Create" paramId="username"
 paramName="registrationForm" paramProperty="username">
  <fmt:message key="registration.addSubscription"/>
</html-el:link>

The value "username" is a key, so it might be better to reference a constant value:
"Constants.USER_NAME_KEY". My question is, how do I do this (without using sriplets)?


If I don't use a quote after paramId=, I get an error when the page compiles. No matter what I
put inside the quotes, it comes into the html as literal.


Any suggestions?

Mike

__________________________________
Do you Yahoo!?
SBC Yahoo! DSL - Now only $29.95 per month!
http://sbc.yahoo.com

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

_________________________________________________________________
Protect your PC - get McAfee.com VirusScan Online http://clinic.mcafee.com/clinic/ibuy/campaign.asp?cid=3963



--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to