RE: RT expr value in custom tag
Good evening... Thanks for the reponse, I realised this shortly after I posted my question and figured asbestos underpants would soon be required. Shame on me not carrying my research just a little further. Although your final note on RT expression evaluation is something I had not yet realised. As for the EL evaluation mechanism, check out the class org.apache.taglibs.standard.lang.support.ExpressionEvaluatorManager in the Jakarta Standard Taglib (I'm looking at v1.0.4). Thanks again. Eric Schultz. -Original Message- From: Van Riper, Mike To: '[EMAIL PROTECTED]' Cc: 'Eric SCHULTZ' Sent: 05/12/03 5:00 PM Subject: RE: RT expr value in custom tag Eric, What you are trying to do doesn't really require the JSTL expression language. All you need to do is specify that runtime expressions are to be evaluated for the "parameter" attribute of your custom tag in your TLD file. If you were to look at any of the TLD files that come with Struts, you would see plenty of examples of this. For example, here is the tag TLD definition that enables runtime expression evaluation for both the "target" and the "server" optional attributes for the tag: base org.apache.struts.taglib.html.BaseTag empty target false true server false true Runtime expression evaluation is what allows you to evaluate Java expressions inside of <%= ...%> for your custom tag parameters. If you use the JSTL expression language (EL), you don't use the Java expression tag. They are two separate ways to refer to dynamic content for custom tag attributes. To use the JSTL EL, you have to build your custom tag such that it has EL support in it. If you really want to go that route, I haven't done that yet myself. So, I can't help you with that. However, you can look at how the contributed taglib (html-el) that extends the HTML taglib of Struts 1.1 to add EL support for the parameters of the Struts HTML custom tags does just that. Also, your example used the <%= ...%> tag correctly for a custom tag parameter. However, many people initially stumble on getting this to work correctly even when runtime expression evaluation is enabled because they try to define only part of the custome tag attribute with the tag. For it to work even when properly enabled for the attribute in the TLD, you have to define the entire contents of the custom tag attribute value to be the <%= ...%> Java expression. If there is static content you want to include as part of the attribute value, you typically use string operations inside the JSP expression to concatenate and build up the final attribute value merging your dynamic and static data. Hope this helps, Van Mike Van Riper Silicon Valley Struts User Group mail: mike.vanriper at baychi.org http://www.baychi.org/bof/struts/ > -Original Message- > From: Eric SCHULTZ [mailto:[EMAIL PROTECTED] > Sent: Friday, December 05, 2003 7:54 AM > To: '[EMAIL PROTECTED]' > Subject: RT expr value in custom tag > > > Good morning... > > I'm trying to write my own custom tag library for Struts. > I've had some > initial success, but now I'm having some trouble. > > I want to set an attribute value from the value of a bean > get. But what I > end up with in my tag is JSP code, not the value in the bean. > > I.e.: > > > is not translated. > > How do I get the result of UserSessionBean.getInputMode() in > my tag? Do I > need to implement Expression Language? Is there already a > utility class > somewhere in Struts 1.1 that would evaluate something like > ${UserSessionBean.inputMode} for me? > > Thanks. > - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: RT expr value in custom tag
Eric, What you are trying to do doesn't really require the JSTL expression language. All you need to do is specify that runtime expressions are to be evaluated for the "parameter" attribute of your custom tag in your TLD file. If you were to look at any of the TLD files that come with Struts, you would see plenty of examples of this. For example, here is the tag TLD definition that enables runtime expression evaluation for both the "target" and the "server" optional attributes for the tag: base org.apache.struts.taglib.html.BaseTag empty target false true server false true Runtime expression evaluation is what allows you to evaluate Java expressions inside of <%= ...%> for your custom tag parameters. If you use the JSTL expression language (EL), you don't use the Java expression tag. They are two separate ways to refer to dynamic content for custom tag attributes. To use the JSTL EL, you have to build your custom tag such that it has EL support in it. If you really want to go that route, I haven't done that yet myself. So, I can't help you with that. However, you can look at how the contributed taglib (html-el) that extends the HTML taglib of Struts 1.1 to add EL support for the parameters of the Struts HTML custom tags does just that. Also, your example used the <%= ...%> tag correctly for a custom tag parameter. However, many people initially stumble on getting this to work correctly even when runtime expression evaluation is enabled because they try to define only part of the custome tag attribute with the tag. For it to work even when properly enabled for the attribute in the TLD, you have to define the entire contents of the custom tag attribute value to be the <%= ...%> Java expression. If there is static content you want to include as part of the attribute value, you typically use string operations inside the JSP expression to concatenate and build up the final attribute value merging your dynamic and static data. Hope this helps, Van Mike Van Riper Silicon Valley Struts User Group mail: mike.vanriper at baychi.org http://www.baychi.org/bof/struts/ > -Original Message- > From: Eric SCHULTZ [mailto:[EMAIL PROTECTED] > Sent: Friday, December 05, 2003 7:54 AM > To: '[EMAIL PROTECTED]' > Subject: RT expr value in custom tag > > > Good morning... > > I'm trying to write my own custom tag library for Struts. > I've had some > initial success, but now I'm having some trouble. > > I want to set an attribute value from the value of a bean > get. But what I > end up with in my tag is JSP code, not the value in the bean. > > I.e.: > > > is not translated. > > How do I get the result of UserSessionBean.getInputMode() in > my tag? Do I > need to implement Expression Language? Is there already a > utility class > somewhere in Struts 1.1 that would evaluate something like > ${UserSessionBean.inputMode} for me? > > Thanks. > - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RT expr value in custom tag
Good morning... I'm trying to write my own custom tag library for Struts. I've had some initial success, but now I'm having some trouble. I want to set an attribute value from the value of a bean get. But what I end up with in my tag is JSP code, not the value in the bean. I.e.: is not translated. How do I get the result of UserSessionBean.getInputMode() in my tag? Do I need to implement Expression Language? Is there already a utility class somewhere in Struts 1.1 that would evaluate something like ${UserSessionBean.inputMode} for me? Thanks. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]