Re: paramId in html-el:link tag - Referenceing a Constant
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]
Re: paramId in html-el:link tag - Referenceing a Constant
Ignore my glaring typos: 2: The fields you want to access must also be true Bean fields: ie: public Static CONSTANT_KEY_1 = a_constant_key; // perhaps used by your code elsewhere public String getConstantKey() { return CONSTANT_KEY_1; } To: [EMAIL PROTECTED] Subject: Re: paramId in html-el:link tag - Referenceing a Constant Date: Mon, 21 Jul 2003 10:43:17 -0500 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] _ Tired of spam? Get advanced junk mail protection with MSN 8. http://join.msn.com/?page=features/junkmail - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
paramId in html-el:link tag - Referenceing a Constant
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]
Re: paramId in html-el:link tag - Referenceing a Constant
Mike == Mike Duffy [EMAIL PROTECTED] writes: Mike The struts-example\registration.jsp contains the following code: Mike html:link page=/editSubscription.do?action=Create paramId=username Mike paramName=registrationForm paramProperty=username Mike bean:message key=registration.addSubscription/ Mike /html:link Mike Switching this to an html-el:link tag is easy. Mike html-el:link page=/editSubscription.do?action=Create paramId=username Mike paramName=registrationForm paramProperty=username Mike fmt:message key=registration.addSubscription/ Mike /html-el:link Mike The value username is a key, so it might be better to reference a constant value: Mike Constants.USER_NAME_KEY. My question is, how do I do this (without using sriplets)? Mike If I don't use a quote after paramId=, I get an error when the page compiles. No matter what I Mike put inside the quotes, it comes into the html as literal. Mike Any suggestions? The EL syntax in this version can reference javabean properties and collection/map entries. That's it. You can do anything that uses those features. You could manually put constant values into a map, and reference the map entries. If you have to do that a lot, you might consider a class that uses reflection to gather constant values from one or more classes into a map, keyed by the constant name (perhaps downcasing the keys). -- === David M. Karr ; Java/J2EE/XML/Unix/C++ [EMAIL PROTECTED] ; SCJP; SCWCD - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]