combining tags
I used to have some JSP code that looked like: logic:iterate name=myForm property=myDataList id=iter html:checkbox name=iter property=checkedRes indexed=true/ bean:write name=iter property=roomType/ html:text name=iter property=numItems indexed=true style=width:40/ /logic:iterate I'd like to switch to something likes this: c:forEach items=${SelectedRoomsForm.roomsList} var=data varStatus=status html:checkbox name=data property=checkedRes indexed=true/ c:out value=${data.roomType}/ html:text name=data property=numItems indexed=true style=width:40/ /c:forEach The c:out tag I am sure works, but I am not sure about the html:checkbox or the html:text Does this code look ok, or is there something I have to change? Thanks. Tom - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: combining tags
Tom - Please see reply below: On 7/6/05, Tom Holmes Jr. [EMAIL PROTECTED] wrote: I used to have some JSP code that looked like: logic:iterate name=myForm property=myDataList id=iter html:checkbox name=iter property=checkedRes indexed=true/ bean:write name=iter property=roomType/ html:text name=iter property=numItems indexed=true style=width:40/ /logic:iterate I'd like to switch to something likes this: c:forEach items=${SelectedRoomsForm.roomsList} var=data varStatus=status html:checkbox name=data property=checkedRes indexed=true/ c:out value=${data.roomType}/ html:text name=data property=numItems indexed=true style=width:40/ /c:forEach The c:out tag I am sure works, but I am not sure about the html:checkbox or the html:text Does this code look ok, or is there something I have to change? Though you can mix and match JSTL and the Struts taglibs, you should be aware of the inter-dependencies between specific tags. For example, the indexed property of the struts-html tags relies on a parent logic:iterate to produce the resulting name attribute. I recommend reading this FAQ page [ http://struts.apache.org/faqs/indexedprops.html ] and the TLD docs in general. If you stare at the markup generated by the first snippet, that will tell you what the JSTL snippet should look like. -Rahul - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: combining tags
From: Tom Holmes Jr. [EMAIL PROTECTED] I'd like to switch to something likes this: c:forEach items=${SelectedRoomsForm.roomsList} var=data varStatus=status html:checkbox name=data property=checkedRes indexed=true/ c:out value=${data.roomType}/ html:text name=data property=numItems indexed=true style=width:40/ /c:forEach The c:out tag I am sure works, but I am not sure about the html:checkbox or the html:text Does this code look ok, or is there something I have to change? Assuming you're not on a JSP 2.0 container (I assume not, or you wouldn't be using c:out) you might want to switch to the Struts-EL tags instead of the 'classic' taglib. With the ability to use expressions in the JSTL tags, you'll quickly get frustrated at NOT being able to do it in the Struts tags. Indexed tags are now supported within c:forEach loops, according to the README.txt file included with Struts-EL. To switch over, look in the 'contrib' directory of the Struts 1.2.7 distribution, get the .jar files and change to: %@ taglib uri=http://struts.apache.org/tags-html-el; prefix=html-el % (Some people leave the prefix as 'html'.) All my checkboxes-within-forEach-loops are 'multibox' not 'checkbox'. But I don't use indexed properties, so YMMV. -- Wendy Smoak - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: combining tags
Wendy Smoak wrote: From: Tom Holmes Jr. [EMAIL PROTECTED] I'd like to switch to something likes this: c:forEach items=${SelectedRoomsForm.roomsList} var=data varStatus=status html:checkbox name=data property=checkedRes indexed=true/ c:out value=${data.roomType}/ html:text name=data property=numItems indexed=true style=width:40/ /c:forEach The c:out tag I am sure works, but I am not sure about the html:checkbox or the html:text Does this code look ok, or is there something I have to change? Assuming you're not on a JSP 2.0 container (I assume not, or you wouldn't be using c:out) you might want to switch to the Struts-EL tags instead of the 'classic' taglib. With the ability to use expressions in the JSTL tags, you'll quickly get frustrated at NOT being able to do it in the Struts tags. Indexed tags are now supported within c:forEach loops, according to the README.txt file included with Struts-EL. To switch over, look in the 'contrib' directory of the Struts 1.2.7 distribution, get the .jar files and change to: %@ taglib uri=http://struts.apache.org/tags-html-el; prefix=html-el % (Some people leave the prefix as 'html'.) All my checkboxes-within-forEach-loops are 'multibox' not 'checkbox'. But I don't use indexed properties, so YMMV. I have no idea if it is a JSP Container 2.0 or not. I can tell you that we are using IBM Websphere 5.1.x Portal Server. I can also tell you that the the imports we are using in our JSP pages look like: %@ taglib uri=/WEB-INF/tld/struts-html.tld prefix=html % %@ taglib uri=/WEB-INF/tld/struts-bean.tld prefix=bean % %@ taglib uri=/WEB-INF/tld/struts-logic.tld prefix=logic % %@ taglib uri=/WEB-INF/tld/c.tld prefix=c % And we are using Struts. My boss has told me at one point that he'd wanted to start using JSTL tags more then the older JSP Tag Libraries. To me, that means using more of the c:? tags, but we still need to use html:? tags. To my boss, that would mean getting more functionality and using expressions as you stated. For example, rather than writing: bean:write name=iter property=selectedStartDate1/ - bean:write name=iter property=selectedEndDate1/br Instead we could do: c:out value=${data.selectedStartDate1} - ${data.selectedEndDate1} / Doesn't that seem easier to understand? I just figured we'd get the same results when we submit the form. When using logic:iterate I understand how we can do c:out just fine. And it works fine with html:text, but it's when we do c:if test= something that I was getting into trouble. It didn't seem to work? As Rahul stated, I'll check the generated HTML source and I'll also check the Action class to see if the data submitted is the same. Thanks for the help. Tom - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: combining tags
From: Tom Holmes Jr. [EMAIL PROTECTED] I have no idea if it is a JSP Container 2.0 or not. I can tell you that we are using IBM Websphere 5.1.x Portal Server. A quick Google search didn't turn up the info-- I'm trying to determine which version of the Servlet specification it implements. My comment was merely that if it's Servlet 2.4/JSP 2.0, you probably would have written ${data.roomType} instead of c:out value=${data.roomType}/. Not that you wouldn't use *any* c:xxx tags. So, let's assume Servlet 2.3/JSP 1.2 for now. And we are using Struts. My boss has told me at one point that he'd wanted to start using JSTL tags more then the older JSP Tag Libraries. To me, that means using more of the c:? tags, but we still need to use html:? tags. My point was that if you're going to add JSTL to a Struts project, you might also want to move to Struts-EL in order to gain the ability to use expressions within the Struts tags, as well as the JSTL-awareness so that indexed properties will work within an enclosing c:forEach loop. http://struts.apache.org/faqs/struts-el.html -- Wendy Smoak - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: combining tags
To clarify some comments from other responders: It is a good idea to use Struts-EL if you're going to use the JSTL. However, for this particular example, the Struts tag library itself has knowledge of c:forEach, as opposed to logic:iterate, so an html Struts tag that uses indexed=true will work inside a c:forEach, at least with respect to generating the correct indexed property values. -Original Message- From: Tom Holmes Jr. [mailto:[EMAIL PROTECTED] Sent: Wednesday, July 06, 2005 8:02 AM To: Tag Libraries Users List Subject: combining tags I used to have some JSP code that looked like: logic:iterate name=myForm property=myDataList id=iter html:checkbox name=iter property=checkedRes indexed=true/ bean:write name=iter property=roomType/ html:text name=iter property=numItems indexed=true style=width:40/ /logic:iterate I'd like to switch to something likes this: c:forEach items=${SelectedRoomsForm.roomsList} var=data varStatus=status html:checkbox name=data property=checkedRes indexed=true/ c:out value=${data.roomType}/ html:text name=data property=numItems indexed=true style=width:40/ /c:forEach The c:out tag I am sure works, but I am not sure about the html:checkbox or the html:text Does this code look ok, or is there something I have to change? Thanks. Tom - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]