Re: Having trouble with JSTL inside JSF
Well, there is a way in MyFaces to do so. check out the t:aliasBean! regards, Martin On 8/26/05, Udo Schnurpfeil [EMAIL PROTECTED] wrote: * The fact that you can use a value binding expression on nearly every attribute makes using rt expressions redundant ... you can do anything you need with a value binding anyway. A very powerful feature in JSP 2.0 are Custom Tags. Having a bean Foo in your application with several instances. Now you write some code to edit this bean. If you put this code into a custom tag like WEB-INF/tags/beans/foo.tag begin -- %@ attribute name=bean % h:outputLabel value=here comes my bean: / h:inputText value=#{${bean}.firstName} / h:inputText value=#{${bean}.secondName} / foo.tag end you can use this snip many times on your jsp like page.jsp begin -- %@ taglib tagdir=/WEB-INF/tags/beans prefix=beans % beans:foo bean=foo1 / beans:foo bean=foo2 / beans:foo bean=foo3 / page.jsp end Unfortunately this does not work. Because of the rtexpression=false. In tobago we decided to enable the feature, to make such things work. Is there a way in JSF 1.2 / JSP 2.1 to make such sniplets run without dublicating code? Udo In JSF 1.2 / JSP 2.1, the concepts are getting unified ... but in the mean time (when the JSP container doesn't know what a value binding expression is) this was the decision made at the JSF spec level. Craig -- http://www.irian.at Your JSF powerhouse - JSF Trainings in English and German
Re: Having trouble with JSTL inside JSF
Hmmm, I worry about this will not solve my problem. I understand the t:aliasBean to use like this: page.jsp begin -- t:aliasBean alias=#{foo} value=#{foo1} / beans:foo / t:aliasBean alias=#{foo} value=#{foo2} / beans:foo / page.jsp end -- and use h:inputText value=#{foo.firstName} / in the custom tag. So far, so good. But, I want to use, of course, the tobago layout manager for layouting: t:panel f:facet name=layoutt:gridLayout ... /f:facet t:aliasBean alias=#{foo} value=#{foo1} / beans:foo / t:aliasBean alias=#{foo} value=#{foo2} / beans:foo / /t:panel The layout manager has to know all of its containers children to make an appropriate layout. So the panel has rendersChilden=true, and all the tags will be parsed before rendering. In the moment where #{foo.firstname} will be evaluated by the renderer (2 times), the value of #{foo} equals #{foo2}, because it will be done at the end tag of the panel (/t:panel). regards Udo Martin Marinschek wrote: Well, there is a way in MyFaces to do so. check out the t:aliasBean! regards, Martin On 8/26/05, Udo Schnurpfeil [EMAIL PROTECTED] wrote: * The fact that you can use a value binding expression on nearly every attribute makes using rt expressions redundant ... you can do anything you need with a value binding anyway. A very powerful feature in JSP 2.0 are Custom Tags. Having a bean Foo in your application with several instances. Now you write some code to edit this bean. If you put this code into a custom tag like WEB-INF/tags/beans/foo.tag begin -- %@ attribute name=bean % h:outputLabel value=here comes my bean: / h:inputText value=#{${bean}.firstName} / h:inputText value=#{${bean}.secondName} / foo.tag end you can use this snip many times on your jsp like page.jsp begin -- %@ taglib tagdir=/WEB-INF/tags/beans prefix=beans % beans:foo bean=foo1 / beans:foo bean=foo2 / beans:foo bean=foo3 / page.jsp end Unfortunately this does not work. Because of the rtexpression=false. In tobago we decided to enable the feature, to make such things work. Is there a way in JSF 1.2 / JSP 2.1 to make such sniplets run without dublicating code? Udo In JSF 1.2 / JSP 2.1, the concepts are getting unified ... but in the mean time (when the JSP container doesn't know what a value binding expression is) this was the decision made at the JSF spec level. Craig -- Dipl.-Math. Udo Schnurpfeil - Executive Officer - Atanion GmbH Software Development - Bismarckstraße 13 - 26122 Oldenburg - Germany phone +49 441 4082310 - mobile +49 174 9784746 - fax +49 441 4082333 mailto:[EMAIL PROTECTED] - http://www.atanion.com
Re: Having trouble with JSTL inside JSF
in fact, you would use the alias bean like this: t:panel f:facet name=layoutt:gridLayout ... /f:facet t:aliasBean alias=#{foo} value=#{foo1} beans:foo / /t:aliasBean t:aliasBean alias=#{foo} value=#{foo2} beans:foo / /t:aliasBean /t:panel but in any case, you are right, the JSF expression is not there any more when you close the t:panel tag. regards, Martin On 8/26/05, Udo Schnurpfeil [EMAIL PROTECTED] wrote: Hmmm, I worry about this will not solve my problem. I understand the t:aliasBean to use like this: page.jsp begin -- t:aliasBean alias=#{foo} value=#{foo1} / beans:foo / t:aliasBean alias=#{foo} value=#{foo2} / beans:foo / page.jsp end -- and use h:inputText value=#{foo.firstName} / in the custom tag. So far, so good. But, I want to use, of course, the tobago layout manager for layouting: t:panel f:facet name=layoutt:gridLayout ... /f:facet t:aliasBean alias=#{foo} value=#{foo1} / beans:foo / t:aliasBean alias=#{foo} value=#{foo2} / beans:foo / /t:panel The layout manager has to know all of its containers children to make an appropriate layout. So the panel has rendersChilden=true, and all the tags will be parsed before rendering. In the moment where #{foo.firstname} will be evaluated by the renderer (2 times), the value of #{foo} equals #{foo2}, because it will be done at the end tag of the panel (/t:panel). regards Udo Martin Marinschek wrote: Well, there is a way in MyFaces to do so. check out the t:aliasBean! regards, Martin On 8/26/05, Udo Schnurpfeil [EMAIL PROTECTED] wrote: * The fact that you can use a value binding expression on nearly every attribute makes using rt expressions redundant ... you can do anything you need with a value binding anyway. A very powerful feature in JSP 2.0 are Custom Tags. Having a bean Foo in your application with several instances. Now you write some code to edit this bean. If you put this code into a custom tag like WEB-INF/tags/beans/foo.tag begin -- %@ attribute name=bean % h:outputLabel value=here comes my bean: / h:inputText value=#{${bean}.firstName} / h:inputText value=#{${bean}.secondName} / foo.tag end you can use this snip many times on your jsp like page.jsp begin -- %@ taglib tagdir=/WEB-INF/tags/beans prefix=beans % beans:foo bean=foo1 / beans:foo bean=foo2 / beans:foo bean=foo3 / page.jsp end Unfortunately this does not work. Because of the rtexpression=false. In tobago we decided to enable the feature, to make such things work. Is there a way in JSF 1.2 / JSP 2.1 to make such sniplets run without dublicating code? Udo In JSF 1.2 / JSP 2.1, the concepts are getting unified ... but in the mean time (when the JSP container doesn't know what a value binding expression is) this was the decision made at the JSF spec level. Craig -- Dipl.-Math. Udo Schnurpfeil - Executive Officer - Atanion GmbH Software Development - Bismarckstraße 13 - 26122 Oldenburg - Germany phone +49 441 4082310 - mobile +49 174 9784746 - fax +49 441 4082333 mailto:[EMAIL PROTECTED] - http://www.atanion.com -- http://www.irian.at Your JSF powerhouse - JSF Trainings in English and German
Re: Having trouble with JSTL inside JSF
Another suggestion: use the x:dataList of Apache MyFaces for each occurence of forEach. Handles this problem pretty well. regards, Martin On 8/23/05, Matthias Wessendorf [EMAIL PROTECTED] wrote: On 8/23/05, Matt Raible [EMAIL PROTECTED] wrote: Unfortunately, JSP EL and JSF EL don't play nicely together. This will be fixed in JSF 1.2 with the Unified EL. In the meantime, here's a hack that should work: It also needs JSP 2.1 to work well. -- http://www.irian.at Your JSF powerhouse - JSF Trainings in English and German
Re: Having trouble with JSTL inside JSF
Hello, unfortunately, the value attribute of h:outputText does not accept any rtexpressions. In jsp 2.1 and if h:outputText would allow any expression you could write this: f:view h:form c:forEach items=${employeeBacking.employees} var=emp varStatus=status h:outputText value=#{employeeBacking.employees[${status.index}]} / /c:forEach /h:form /f:view In tobago you can write this: f:view t:page c:forEach items=${employeeBacking.employees} var=emp varStatus=status t:out value=#{employeeBacking.employees[${status.index}]} / /c:forEach /t:page /f:view you can find a working example at http://www.atanion.net/repos/asf/tobago/trunk in example/foreach Bernd Matt Raible wrote: Unfortunately, JSP EL and JSF EL don't play nicely together. This will be fixed in JSF 1.2 with the Unified EL. In the meantime, here's a hack that should work: %-- Step 1: Use a non-displayed dataTable to pull userList into request --% h:dataTable var=employee value=#{employeeBacking.employee} style=display:none/ c:forEach items=${employeeBacking.employees} var=emp varStatus=status c:out value=${status.index}/br/ /c:forEach You could also use an h:dataTable to do the iteration. Hope this helps, Matt On Aug 23, 2005, at 9:50 AM, Rick Reumann wrote: I understand the below won't work as is without the backing bean put in scope with a useBean construct...but I'm more curious why I can not get c:out to evaluate (or really I should also just be able to use ${..} without the c:out since using tomcat5). What I end up getting is the literal text ${status.index} being displayed. I've tried with commons-el.jar and without and the same result:( %@ taglib uri=http://java.sun.com/jsf/core; prefix=f % %@ taglib uri=http://java.sun.com/jsf/html; prefix=h % %@ taglib uri=http://java.sun.com/jsp/jstl/core; prefix=c % f:view h:form c:forEach items=${employeeBacking.employees} var=emp varStatus=status c:out value=${status.index}/br/ /c:forEach /h:form /f:view -- Dipl.-Ing. Bernd Bohmann - Atanion GmbH - Software Development Bismarckstr. 13, 26122 Oldenburg, http://www.atanion.com phone: +49 441 4082312, mobile: +49 173 8839471, fax: +49 441 4082333
Re: Having trouble with JSTL inside JSF
One question: why the value attribute of x:outputText doesn't accept rtexpressions? regards Bernd Martin Marinschek wrote: Another suggestion: use the x:dataList of Apache MyFaces for each occurence of forEach. Handles this problem pretty well. regards, Martin On 8/23/05, Matthias Wessendorf [EMAIL PROTECTED] wrote: On 8/23/05, Matt Raible [EMAIL PROTECTED] wrote: Unfortunately, JSP EL and JSF EL don't play nicely together. This will be fixed in JSF 1.2 with the Unified EL. In the meantime, here's a hack that should work: It also needs JSP 2.1 to work well. -- Dipl.-Ing. Bernd Bohmann - Atanion GmbH - Software Development Bismarckstr. 13, 26122 Oldenburg, http://www.atanion.com phone: +49 441 4082312, mobile: +49 173 8839471, fax: +49 441 4082333
Re: Having trouble with JSTL inside JSF
On 8/24/05, Bernd Bohmann [EMAIL PROTECTED] wrote: One question: why the value attribute of x:outputText doesn't accept rtexpressions? It's not just this attribute ... the restriction is pretty much universal across all attributes on all component tags. There are two reasons for this: * If rtexpressions were allowed, there would be cases where the RT expression could return a JSF value binding expression, which would then be invoked ... and there are potential security issues with this (pretty much like how webapps can be subject to cross site scripting attacks if they allow arbitrary code to be emitted). * The fact that you can use a value binding expression on nearly every attribute makes using rt expressions redundant ... you can do anything you need with a value binding anyway. In JSF 1.2 / JSP 2.1, the concepts are getting unified ... but in the mean time (when the JSP container doesn't know what a value binding expression is) this was the decision made at the JSF spec level. Bernd Craig
Having trouble with JSTL inside JSF
I understand the below won't work as is without the backing bean put in scope with a useBean construct...but I'm more curious why I can not get c:out to evaluate (or really I should also just be able to use ${..} without the c:out since using tomcat5). What I end up getting is the literal text ${status.index} being displayed. I've tried with commons-el.jar and without and the same result:( %@ taglib uri=http://java.sun.com/jsf/core prefix=f % %@ taglib uri=http://java.sun.com/jsf/html prefix=h % %@ taglib uri=http://java.sun.com/jsp/jstl/core prefix=c % f:view h:form c:forEach items=${employeeBacking.employees} var=emp varStatus=status c:out value=${status.index}/br/ /c:forEach /h:form /f:view
Re: Having trouble with JSTL inside JSF
Unfortunately, JSP EL and JSF EL don't play nicely together. This will be fixed in JSF 1.2 with the Unified EL. In the meantime, here's a hack that should work:%-- Step 1: Use a non-displayed dataTable to pull userList into request --%h:dataTable var="employee" value="#{employeeBacking.employee}" style="display:none"/ c:forEach items="${employeeBacking.employees}" var="emp" varStatus="status" c:out value="${status.index}"/br/ /c:forEachYou could also use an h:dataTable to do the iteration.Hope this helps,MattOn Aug 23, 2005, at 9:50 AM, Rick Reumann wrote:I understand the below won't work as is without the backing bean put in scope with a useBean construct...but I'm more curious why I can not get c:out to evaluate (or really I should also just be able to use ${..} without the c:out since using tomcat5). What I end up getting is the literal text ${status.index} being displayed. I've tried with commons-el.jar and without and the same result:( %@ taglib uri="http://java.sun.com/jsf/core" prefix="f" % %@ taglib uri="http://java.sun.com/jsf/html" prefix="h" % %@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" % f:view h:form c:forEach items="${employeeBacking.employees}" var="emp" varStatus="status" c:out value="${status.index}"/br/ /c:forEach /h:form /f:view
Re: Having trouble with JSTL inside JSF
On 8/23/05, Matt Raible [EMAIL PROTECTED] wrote: Unfortunately, JSP EL and JSF EL don't play nicely together. This will be fixed in JSF 1.2 with the Unified EL. In the meantime, here's a hack that should work: It also needs JSP 2.1 to work well.