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

Reply via email to