You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Clint Popetz <cl...@cpopetz.com> on 2006/01/23 20:25:00 UTC

html-el:select and tag files

Hello,

	This may be more of a jsp 2.0 question than a html-el tag
library question, but here goes.

	I have a jsp page that has a list of dates that need to be
entered.  I have a custom tag file that displays a date selector using
three html-el: selects (year/month/day.)  It takes as attributes the
form property name and the index.  The dyna form bean, for legacy
reasons, does not contain an array of date objects, but rather three
arrays of integers, one for date, one for month, and one for year.  So
the form bean looks like:

          <form-property name="prop_date" type="java.lang.Integer[]"/>
          <form-property name="prop_month" type="java.lang.Integer[]"/>
          <form-property name="prop_year" type="java.lang.Integer[]"/>

and the tag library looks like (without its header):

	<%@ attribute name="property" required="true" %>
	<%@ attribute name="index"    required="true" %>

	<html-el:select property="${property}_date[${index}]">
	   <!-- bunch of options here -->
	</html-el:select>

	<html-el:select property="${property}_month[${index}]">
	  <!-- bunch of options here -->
	</html-el:select>

	<html-el:select property="${property}_year[${index}]">
	  <!-- bunch of options here -->
	</html-el:select>


The problem I face is that let's say the jsp using the tag does this:

	<c:forEach var="foo" items="${someFoos}" varStatus="status">

		<myTagLib:dateSelect property="prop" index="${status.index}"/>

	</c:forEach>

Then I get:

    javax.servlet.jsp.JspException: Invalid indexed property 'prop_date[${status'

presumadely from the html-el:select.  I'm assuming that status.index
isn't getting evaluated when invoking the dateSelect tag, and so when
${property}_month[${index}] is evaluated by the html-el:select tag, it
gets 'prop_date[${status.index}]' and doesn't recursively evaluate to
find the value of status.index.  Any suggestions on the correct way to
deal with this?

			Thanks,
			-Clint



---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: html-el:select and tag files

Posted by Rahul Akolkar <ra...@gmail.com>.
On 1/23/06, Clint Popetz <cl...@cpopetz.com> wrote:
> On Mon, Jan 23, 2006 at 03:00:27PM -0500, Rahul Akolkar wrote:
> > On 1/23/06, Clint Popetz <cl...@cpopetz.com> wrote:
> > > On Mon, Jan 23, 2006 at 12:36:02PM -0700, Wendy Smoak wrote:
<snip/>
> > > >
> > > > Use the plain HTML tags and make sure you've configured your webapp
> > > > for Servlet 2.4 so that the container will evaluate the expressions
> > > > prior to passing them into the tags.
> > >
> > > I had no idea this was even possible.  Can you point me to a reference
> > > on configuring tomcat 5.5.x do that?
> >
> > Doesn't take much:
> >
> > http://wiki.apache.org/jakarta-taglibs/FrequentlyAskedQuestions
>
> Ok, I am sorry for the confusion.  I had assumed that because I was
> running tomcat5.5 and tag files were working, I was in jsp 2.0 land,
> but I had no version attribute for the web-app declaratipon in
> web.xml, and the DOCTYPE was pointing to 2.3.  I tried changing it to
> what is suggested by the FAQ, but that results in all of my jstl tags
> failing to compile.  I just read the Jstl-1.1 appendix on compatibilty
> and discovered that jstl-1.1 defaults to jstl-1.0 mode when running in
> with a web.xml set to 2.3, so that makes sense.
>
> I can't possibly update all my uses of jstl at this point in order to
> run with jstl-1.1, so it seems I'm running under 2.3 for the time
> being.
>
<snap/>

You might also want to look at the 1.0 --> 1.1 migration roadmap laid
out in the spec. In some cases, it isn't too much work.


> Now, given that I'm running under jsp 1.2, not 2.0, and thus using the
> struts-el tags, my original question still stands.  I won't re-quote
> it, for space concerns.  Basically, a EL expression is passed from a
> page into a tag file via an attribute, and then passed to struts-el as
> a property, but I get one-two-few EL evaluations, and thus end up with
> a property name that has el expressions in it but is treated as a bean
> property literally.
>
<snip/>

1.2 didn't have tag files, so all bets are off. Some servlet
containers might blow up with an audible bang ;-)


>                        Thanks,
>                        -Clint
>
> P.S.  Magic behaviors are dangerous.  The fact that the text "2.4" versus
> the text "2.3" in my web.xml turns off container jsp-el parsing _and_
> toggles jstl 1.0 verses 1.1 is a little much.  My $.02.
>
<snap/>

Its not so much that you changed one character in your web.xml, but
what the semantics of the version attribute are in the web application
descriptor. Non-trivial.

-Rahul

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: html-el:select and tag files

Posted by Clint Popetz <cl...@cpopetz.com>.
On Mon, Jan 23, 2006 at 03:00:27PM -0500, Rahul Akolkar wrote:
> On 1/23/06, Clint Popetz <cl...@cpopetz.com> wrote:
> > On Mon, Jan 23, 2006 at 12:36:02PM -0700, Wendy Smoak wrote:
> > > On 1/23/06, Clint Popetz <cl...@cpopetz.com> wrote:
> > >
> > > >         This may be more of a jsp 2.0 question than a html-el tag
> > > > library question, but here goes.
> > >
> > > If you're using JSP 2.0, you should not be using Struts-EL.
> > >
> > > Use the plain HTML tags and make sure you've configured your webapp
> > > for Servlet 2.4 so that the container will evaluate the expressions
> > > prior to passing them into the tags.
> >
> > I had no idea this was even possible.  Can you point me to a reference
> > on configuring tomcat 5.5.x do that?  
> 
> Doesn't take much:
> 
> http://wiki.apache.org/jakarta-taglibs/FrequentlyAskedQuestions

Ok, I am sorry for the confusion.  I had assumed that because I was
running tomcat5.5 and tag files were working, I was in jsp 2.0 land,
but I had no version attribute for the web-app declaratipon in
web.xml, and the DOCTYPE was pointing to 2.3.  I tried changing it to
what is suggested by the FAQ, but that results in all of my jstl tags
failing to compile.  I just read the Jstl-1.1 appendix on compatibilty
and discovered that jstl-1.1 defaults to jstl-1.0 mode when running in
with a web.xml set to 2.3, so that makes sense.  

I can't possibly update all my uses of jstl at this point in order to
run with jstl-1.1, so it seems I'm running under 2.3 for the time
being.

Now, given that I'm running under jsp 1.2, not 2.0, and thus using the
struts-el tags, my original question still stands.  I won't re-quote
it, for space concerns.  Basically, a EL expression is passed from a
page into a tag file via an attribute, and then passed to struts-el as
a property, but I get one-two-few EL evaluations, and thus end up with
a property name that has el expressions in it but is treated as a bean
property literally.

			Thanks,
			-Clint

P.S.  Magic behaviors are dangerous.  The fact that the text "2.4" versus
the text "2.3" in my web.xml turns off container jsp-el parsing _and_
toggles jstl 1.0 verses 1.1 is a little much.  My $.02.

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: html-el:select and tag files

Posted by Rahul Akolkar <ra...@gmail.com>.
On 1/23/06, Clint Popetz <cl...@cpopetz.com> wrote:
> On Mon, Jan 23, 2006 at 12:36:02PM -0700, Wendy Smoak wrote:
> > On 1/23/06, Clint Popetz <cl...@cpopetz.com> wrote:
> >
> > >         This may be more of a jsp 2.0 question than a html-el tag
> > > library question, but here goes.
> >
> > If you're using JSP 2.0, you should not be using Struts-EL.
> >
> > Use the plain HTML tags and make sure you've configured your webapp
> > for Servlet 2.4 so that the container will evaluate the expressions
> > prior to passing them into the tags.
>
> I had no idea this was even possible.  Can you point me to a reference
> on configuring tomcat 5.5.x do that?  I couldn't find anything in
>
>        http://tomcat.apache.org/tomcat-5.5-doc/jasper-howto.html
>
> to configure the Jsp servlet to do that.  Also, for testing I use the
> jasper ant task to compile the jsps, and the resulting java is
> definitely not pre-evaluating the strings passed into the html: (or
> htm-el:) tags.  How do I convince jasper to do that?
>
<snip/>

Doesn't take much:

http://wiki.apache.org/jakarta-taglibs/FrequentlyAskedQuestions

-Rahul


>                                Thanks,
>                                -Clint
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: html-el:select and tag files

Posted by Rahul Akolkar <ra...@gmail.com>.
On 1/23/06, Michael Jouravlev <jm...@gmail.com> wrote:
<snip/>
>
> You don't need to configure it (if you don't want to turn EL off). EL
> is simply what JSP 2.0 container does. EL and JSTL are part of JSP 2.0
> spec.
>
<snap/>

JSTL is not part of JSP 2.0. They're separate JSRs (52 and 152 respectively).

-Rahul


>
> Michael.
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: html-el:select and tag files

Posted by Michael Jouravlev <jm...@gmail.com>.
On 1/23/06, Clint Popetz <cl...@cpopetz.com> wrote:
> On Mon, Jan 23, 2006 at 12:36:02PM -0700, Wendy Smoak wrote:
> > On 1/23/06, Clint Popetz <cl...@cpopetz.com> wrote:
> >
> > >         This may be more of a jsp 2.0 question than a html-el tag
> > > library question, but here goes.
> >
> > If you're using JSP 2.0, you should not be using Struts-EL.
> >
> > Use the plain HTML tags and make sure you've configured your webapp
> > for Servlet 2.4 so that the container will evaluate the expressions
> > prior to passing them into the tags.
>
> I had no idea this was even possible.  Can you point me to a reference
> on configuring tomcat 5.5.x do that?  I couldn't find anything in
>
>         http://tomcat.apache.org/tomcat-5.5-doc/jasper-howto.html
>
> to configure the Jsp servlet to do that.

You don't need to configure it (if you don't want to turn EL off). EL
is simply what JSP 2.0 container does. EL and JSTL are part of JSP 2.0
spec.

Michael.

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: html-el:select and tag files

Posted by Clint Popetz <cl...@cpopetz.com>.
On Mon, Jan 23, 2006 at 12:36:02PM -0700, Wendy Smoak wrote:
> On 1/23/06, Clint Popetz <cl...@cpopetz.com> wrote:
> 
> >         This may be more of a jsp 2.0 question than a html-el tag
> > library question, but here goes.
> 
> If you're using JSP 2.0, you should not be using Struts-EL.
> 
> Use the plain HTML tags and make sure you've configured your webapp
> for Servlet 2.4 so that the container will evaluate the expressions
> prior to passing them into the tags.

I had no idea this was even possible.  Can you point me to a reference
on configuring tomcat 5.5.x do that?  I couldn't find anything in

	http://tomcat.apache.org/tomcat-5.5-doc/jasper-howto.html 

to configure the Jsp servlet to do that.  Also, for testing I use the
jasper ant task to compile the jsps, and the resulting java is
definitely not pre-evaluating the strings passed into the html: (or
htm-el:) tags.  How do I convince jasper to do that?

				Thanks,
				-Clint

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: html-el:select and tag files

Posted by Wendy Smoak <ws...@gmail.com>.
On 1/23/06, Clint Popetz <cl...@cpopetz.com> wrote:

>         This may be more of a jsp 2.0 question than a html-el tag
> library question, but here goes.

If you're using JSP 2.0, you should not be using Struts-EL.

Use the plain HTML tags and make sure you've configured your webapp
for Servlet 2.4 so that the container will evaluate the expressions
prior to passing them into the tags.

--
Wendy

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org