Hi Ben,
Facelets has its own implementation of JSTL (more precisely a subset). The
side effect of that is that even before JSF 1.2, people were able to use
JSTL without the known (evaluation order) problems when under Facelets. In
fact from what I undertood until know on Facelets: there are two phases: one
compilation and one runtime. Tags are either in one or the other phase: this
makes some unexpected behaviour ex
<tc:sheet var="me" ... >
<c:if test="#{me.here}">
.. do sth
this won't work because c:if is evaluated at compile time (this means the
time when the view tree is constructed) at that time tc:sheet didn't still
evaluate so you will always have one and only call to me.isHere() where me
will always be null.
The best thing to do is to give precedence to the rendered attribute for
avery panel box or other comp and use c:if in the cases where ther's no
other possibility.
Regards,
Zied
2007/10/2, Ben Smith <[EMAIL PROTECTED]>:
>
> Actually, as I understand it
>
> http://java.sun.com/jstl/core
>
> is the namespace for JSTL 1.0 (compatible with JSP < 2.0), while
>
> http://java.sun.com/jsp/jstl/core
>
> is the namespace for JSTL >= 1.1 that uses features in JSP >= 2.0.
>
> I had quite a few problems because I was trying to use JSP 2.x
> features with the JSTL 1.0 namespace. Even if you have a JSTL 1.2
> jar, if you use the 1.0 namespace you get JSTL 1.0.
>
> I don't know how all of this relates to facelets and Tobago, but it
> definitely makes a difference if you're trying to use JSF 1.2
> features.
>
> --Ben
>
> On 9/27/07, Zied Hamdi <[EMAIL PROTECTED]> wrote:
> > Sorry erratum,
> >
> > The namespace used by facelets jstl is
> >
> > http://java.sun.com/jstl/core
> > and not
> >
> > http://java.sun.com/jsp/jstl/core
> > that was the problem. Too much noise for nothing.
> >
> > Regards,
> > Zied
> >
> >
> > 2007/9/27, Zied Hamdi <[EMAIL PROTECTED]>:
> > >
> > > Hi again,
> > >
> > > So to answer to people who could encounter the same problem as me:
> > facelets is bundled with its ows JSTL implementation (you were right
> Volker
> > ;-) that has nothing to do with the standard one except that it copies
> its
> > syntax:
> >
> https://facelets.dev.java.net/nonav/docs/dev/docbook.html#taglib-available-jstl
> > .
> > >
> > > The biggest probem is that where your <c:if goes when it's called
> isn't
> > easy to follow at all. I realized it doesn't go into
> > com.sun.facelets.tag.jstl.core. IfHandler (added a breakpoint). A big
> > mistake (in my opinion) is that facelets gives his implementation the
> same
> > namespace as the one for standard JSTL: xmlns:c =
> > http://java.sun.com/jsp/jstl/core
> > > This is a problem because the objective of namespaces is to
> distinguish
> > between implementations of different types, it is amplified because wen
> you
> > have a jstl jar in you classpath, the code is redirected to it (at least
> > that's what happened to me)
> > >
> > > So even though I removed all my jars from my app jstl.jar (and
> > standard.jar) files, JBoss has in its default libs jstl.jar that he puts
> for
> > all applications. \JBoss\server\default \deploy\jboss-web.deployer\(that is
> > copied to JBoss\server\default\tmp\deploy)
> > >
> > > Even after removing this jar, my calls didn't redirect to IfHandler
> > (surely another perverse jstl implementation somewhere) so to be radical
> I
> > changed the namespace like this: I copied the init code in
> JstlCoreLibrary
> > into my own library:
> > >
> > >
> > >
> > > package fr.into.common.functions;
> > >
> > >
> > >
> > > import java.lang.reflect.Method;
> > >
> > > import java.lang.reflect.Modifier;
> > >
> > >
> > >
> > > import com.sun.facelets.tag.AbstractTagLibrary;
> > >
> > > import com.sun.facelets.tag.jstl.core.CatchHandler ;
> > >
> > > import com.sun.facelets.tag.jstl.core.ChooseHandler ;
> > >
> > > import
> > com.sun.facelets.tag.jstl.core.ChooseOtherwiseHandler ;
> > >
> > > import com.sun.facelets.tag.jstl.core.ChooseWhenHandler ;
> > >
> > > import com.sun.facelets.tag.jstl.core.ForEachHandler ;
> > >
> > > import com.sun.facelets.tag.jstl.core.IfHandler;
> > >
> > > import com.sun.facelets.tag.jstl.core.SetHandler;
> > >
> > >
> > >
> > > public class CommonFunctionsTagLibrary extends AbstractTagLibrary {
> > >
> > > public static final String
> > NAMESPACE = "
> > http://www.into-i.fr/facelets/common/functions";
> > >
> > > public static final CommonFunctionsTagLibrary INSTANCE =
> new
> > CommonFunctionsTagLibrary();
> > >
> > >
> > >
> > > public CommonFunctionsTagLibrary() {
> > >
> > > super( NAMESPACE );
> > >
> > >
> > >
> > > try {
> > >
> > > Method[] methods =
> > CommonFunctions.class.getMethods();
> > >
> > >
> > >
> > > for( int i = 0; i < methods.length; i++ ) {
> > >
> > > if( Modifier.isStatic(
> methods[i].getModifiers() )
> > ) {
> > >
> > > addFunction( methods[i].getName(),
> > methods[i] );
> > >
> > > }
> > >
> > > }
> > >
> > > } catch( Exception e ) {
> > >
> > > throw new RuntimeException( e );
> > >
> > > }
> > >
> > > this.addTagHandler( "if", IfHandler.class );
> > >
> > >
> > >
> > > this.addTagHandler( "forEach", ForEachHandler.class );
> > >
> > >
> > >
> > > this.addTagHandler( "catch", CatchHandler.class );
> > >
> > >
> > >
> > > this.addTagHandler( "choose", ChooseHandler.class );
> > >
> > >
> > >
> > > this.addTagHandler( "when", ChooseWhenHandler.class );
> > >
> > >
> > >
> > > this.addTagHandler( "otherwise",
> ChooseOtherwiseHandler.class
> > );
> > >
> > >
> > >
> > > this.addTagHandler( "set", SetHandler.class );
> > >
> > > }
> > >
> > >
> > >
> > > }
> > >
> > > see this link for creating your own libs:
> > http://www.ibm.com/developerworks/java/library/j-facelets2.html
> > >
> > > So now I don't use the standard namespace anymore but it works.
> > >
> > > Hope it will help someone :-)
> > >
> > >
> > > Regards,
> > > Zied
> > >
> > >
> > > 2007/9/26, Zied Hamdi <[EMAIL PROTECTED]>:
> > > >
> > > > Hi Volker,
> > > >
> > > > JSTL can be used in facelets: I found that in an article
> > http://www.ibm.com/developerworks/java/library/j-facelets/
> > > >
> > > > In the article, the snippet
> > > > <c:if test="${empty label}">
> > > > <c:set var="label" value="${fieldName}" />
> > > > </c:if>
> > > >
> > > > comes very handy. The rendered attribute can't do the work anymore
> in
> > such cases.
> > > >
> > > > I didn't see Bernd in posts these last days, maybe he's in holidays.
> > > >
> > > > Regards,
> > > > Zied
> > > >
> > > >
> > > > 2007/9/26, Volker Weber <[EMAIL PROTECTED]>:
> > > >
> > > > > Hi Zied,
> > > > >
> > > > > i have no experience with facelets, but afaik jstl is a jsp taglib
> and
> > > > > not facelets compatible.
> > > > >
> > > > > i never tested tobago with 1.2 maybe bernd knows more.
> > > > >
> > > > >
> > > > > Regards,
> > > > > Volker
> > > > >
> > > > > 2007/9/26, Zied Hamdi < [EMAIL PROTECTED]>:
> > > > > > Hi again,
> > > > > >
> > > > > > Sorry for spamming, I forgot to say it's possible to do wihout
> JSTL
> > playing
> > > > > > with the rendered attribute or using tc:sheet or tc:forEach. The
> > question
> > > > > > is: is tobago still not compatible with JSTL under JSF 1.2?
> > > > > >
> > > > > > Regards,
> > > > > > Zied
> > > > > >
> > > > > >
> > > > > > 2007/9/26, Zied Hamdi < [EMAIL PROTECTED]>:
> > > > > > >
> > > > > > > Hi,
> > > > > > >
> > > > > > > I'm under JSF 1.2 (RI), Facelets 1.12 and a Tobago nightly
> 1.0.12
> > of
> > > > > > yesterday, I'm trying to use JSTL 1.1 but even the simplest
> example
> > fails:
> > > > > > >
> > > > > > >
> > > > > > > < c:if test= "false" >
> > > > > > >
> > > > > > > < tc:out value ="test" ></tc:out >
> > > > > > >
> > > > > > > </ c:if >
> > > > > > >
> > > > > > > prints "test" anyway.
> > > > > > >
> > > > > > > Even more strange : when calling
> > > > > > >
> > > > > > >
> > > > > > > < c:if test=' #{icf:instanceOf( "str", "
> > java.lang.Long" )}' >
> > > > > > >
> > > > > > > < tc:out value ="test2" ></tc:out >
> > > > > > >
> > > > > > > </ c:if >Where instanceOf is a function of mine,
> the
> > function
> > > > > > is executed but its result seems to be ignored anyway.
> > > > > > >
> > > > > > > The problem is not only with c:if. The tag c:forEach enters
> the
> > loop only
> > > > > > once (when items are numerous) and fills its var argument with
> null.
> > > > > > >
> > > > > > > Browsing the mailing list I've found a lot of posts talking
> about
> > using
> > > > > > JSTL and some seem to discourage using it with tobago, but some
> seem
> > to use
> > > > > > it without problems.
> > > > > > >
> > > > > > > I also have these error logs, that maybe related to the
> problem:
> > > > > > >
> > > > > > >
> > > > > > > 5:33 :48,375 INFO [STDOUT] 2007-09-26 15:33 :48,375
> > > > > > [ http-127.0.0.1-8080-3] ERROR
> > > > > >
> > org.apache.myfaces.tobago.webapp.TobagoResponseWriterImpl.endElement
> > (242)
> > > > > > - Element end with name='div' doesn't match with top element on
> the
> > > > > > stack='c:if' ( GridLayoutRenderer.java:381 )
> > > > > > >
> > > > > > > 15:33 :48,375 INFO [STDOUT] 2007-09-26 15:33 :48,375
> > > > > > [http-127.0.0.1-8080-3] ERROR
> > > > > >
> > org.apache.myfaces.tobago.webapp.TobagoResponseWriterImpl.endElement
> > (242)
> > > > > > - Element end with name='td' doesn't match with top element on
> the
> > > > > > stack='div' ( GridLayoutRenderer.java:382 )
> > > > > > >
> > > > > > > 15:33 :48,375 INFO [STDOUT] 2007-09-26 15:33 :48,375
> > > > > > [http-127.0.0.1-8080-3] ERROR
> > > > > >
> > org.apache.myfaces.tobago.webapp.TobagoResponseWriterImpl.endElement
> > (242)
> > > > > > - Element end with name='tr' doesn't match with top element on
> the
> > > > > > stack='td' ( GridLayoutRenderer.java:388 )
> > > > > > >
> > > > > > > 15:33 :48,375 INFO [STDOUT] 2007-09-26 15:33 :48,375
> > > > > > [http-127.0.0.1-8080-3] ERROR
> > > > > >
> > org.apache.myfaces.tobago.webapp.TobagoResponseWriterImpl.endElement
> > (242)
> > > > > > - Element end with name='c:if' doesn't match with top element on
> the
> > > > > > stack='div' ( EndElementInstruction.java:39 )
> > > > > > >
> > > > > > > 15:33 :48,390 INFO [STDOUT] 2007-09-26 15:33 :48,390
> > > > > > [http-127.0.0.1-8080-3] ERROR
> > > > > >
> > org.apache.myfaces.tobago.webapp.TobagoResponseWriterImpl.endElement
> > (242)
> > > > > > - Element end with name='div' doesn't match with top element on
> the
> > > > > > stack='td' ( GridLayoutRenderer.java:381 )
> > > > > > >
> > > > > > > 15:33 :48,390 INFO [STDOUT] 2007-09-26 15:33 :48,390
> > > > > > [http-127.0.0.1-8080-3] ERROR
> > > > > >
> > org.apache.myfaces.tobago.webapp.TobagoResponseWriterImpl.endElement
> > (242)
> > > > > > - Element end with name='td' doesn't match with top element on
> the
> > > > > > stack='tr' ( GridLayoutRenderer.java:382 )
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > Can you please confirm me if it's a bug or if I have to
> continue
> > > > > > investigation?
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > Regards,
> > > > > > >
> > > > > > > Zied
> > > > > >
> > > > > >
> > > > > >
> > > > > > --
> > > > > > Zied Hamdi
> > > > > > zatreex.sourceforge.net
> > > > >
> > > >
> > > >
> > > >
> > > > --
> > > >
> > > > Zied Hamdi
> > > > zatreex.sourceforge.net
> > >
> > >
> > >
> > > --
> > >
> > > Zied Hamdi
> > > zatreex.sourceforge.net
> >
> >
> >
> > --
> >
> > Zied Hamdi
> > zatreex.sourceforge.net
>
--
Zied Hamdi
zatreex.sourceforge.net