add spring taglibs in a jsf page

817 views
Skip to first unread message

Andree Tago

unread,
May 24, 2014, 8:31:04 PM5/24/14
to spring-secu...@googlegroups.com

i want to explor the spring security taglibs in my xhtml page so for that i do this steps:

1) create a springsecurity.taglib.xml:

<?xml version="1.0"?>
<!DOCTYPE facelet-taglib PUBLIC
  "-//Sun Microsystems, Inc.//DTD Facelet Taglib 1.0//EN"
  "http://java.sun.com/dtd/facelet-taglib_1_0.dtd">
<facelet-taglib>
    <namespace>http://www.springframework.org/security/tags</namespace>
    <tag>
        <tag-name>authorize</tag-name>
        <handler-class>org.springframework.faces.security.FaceletsAuthorizeTagHandler</handler-class>
    </tag>
    <function>
        <function-name>areAllGranted</function-name>
        <function-class>org.springframework.faces.security.FaceletsAuthorizeTagUtils</function-class>
        <function-signature>boolean areAllGranted(java.lang.String)</function-signature>
    </function>
    <function>
        <function-name>areAnyGranted</function-name>
        <function-class>org.springframework.faces.security.FaceletsAuthorizeTagUtils</function-class>
        <function-signature>boolean areAnyGranted(java.lang.String)</function-signature>
    </function>
    <function>
        <function-name>areNotGranted</function-name>
        <function-class>org.springframework.faces.security.FaceletsAuthorizeTagUtils</function-class>
        <function-signature>boolean areNotGranted(java.lang.String)</function-signature>
    </function>
    <function>
        <function-name>isAllowed</function-name>
        <function-class>org.springframework.faces.security.FaceletsAuthorizeTagUtils</function-class>
        <function-signature>boolean isAllowed(java.lang.String, java.lang.String)</function-signature>
    </function>
</facelet-taglib>

2) Register the above file in web.xml

<context-param>
        <param-name>javax.faces.FACELETS_LIBRARIES</param-name>
        <param-value>/WEB-INF/springsecurity.taglib.xml</param-value>
</context-param>

when i deploy my project I get an error that requires me to add a spring-faces to solve it, but i get a new problem that the jsf url parametred no longer works((like http://localhost:8080/projet/etudiant.jsf?idEtudiant=2 )). before adding the spring-faces dependency it work's fine, the problem begin when i add this dependency of spring-faces

I need your help very urgent.

Dominik Dorn

unread,
May 25, 2014, 3:59:58 AM5/25/14
to spring-secu...@googlegroups.com
afaik spring added native jsf 2 support to their spring security package a while ago. 
have you tried their library? 




--

---
You received this message because you are subscribed to the Google Groups "Spring Security Facelets-JSF 2.0-taglib" group.
To unsubscribe from this group and stop receiving emails from it, send an email to spring-security-t...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Dominik Dorn
http://dominikdorn.com
http://twitter.com/domdorn

Skripten, Mitschriften, Lernunterlagen, etc. findest Du auf http://www.studyguru.eu !

Andree Tago

unread,
May 25, 2014, 6:26:15 AM5/25/14
to spring-secu...@googlegroups.com
 i dont understand what do you mean you can be a little clearer

Denis Kniazhev

unread,
May 25, 2014, 7:08:14 AM5/25/14
to spring-secu...@googlegroups.com
I guess you don't need spring-security-taglib library anymore since its functionality is now built into spring itself. Please take a look at these docs:



On Sun, May 25, 2014 at 1:26 PM, Andree Tago <andre...@gmail.com> wrote:
 i dont understand what do you mean you can be a little clearer

--

Andree Tago

unread,
May 25, 2014, 7:42:03 AM5/25/14
to spring-secu...@googlegroups.com
if you read my i do the same steps of  
http://stackoverflow.com/questions/7915134/how-to-use-the-spring-security-facelets-tag-library-in-jsf

but my problem is with spring-faces if i add in my project the jsf url parameter will not work you undrestnd me now  

Andree Tago

unread,
May 25, 2014, 9:33:09 AM5/25/14
to spring-secu...@googlegroups.com
my problem is with spring-faces : i flow the exact steps but when i deploy a project i get error :


25 mai 2014 15:29:04 com.sun.faces.config.ConfigureListener contextInitialized
INFO: Initialisation de Mojarra 2.1.4 (SNAPSHOT 20111107) pour le contexte «/afh»
25 mai 2014 15:29:05 com.sun.faces.spi.InjectionProviderFactory createInstance
INFO: JSF1048 : Présence d’annotations PostConstruct/PreDestroy  Les méthodes de beans gérés marquées avec ces annotations auront des annotations dites traitées.
25 mai 2014 15:29:06 com.sun.faces.config.ConfigureListener contextInitialized
GRAVE: Critical error during deployment: 
com.sun.faces.config.ConfigurationException: java.lang.ClassNotFoundException: org.springframework.faces.security.FaceletsAuthorizeTagHandler
at com.sun.faces.config.processor.FaceletTaglibConfigProcessor.processHandlerClass(FaceletTaglibConfigProcessor.java:436)
at com.sun.faces.config.processor.FaceletTaglibConfigProcessor.processTags(FaceletTaglibConfigProcessor.java:371)
at com.sun.faces.config.processor.FaceletTaglibConfigProcessor.processTagLibrary(FaceletTaglibConfigProcessor.java:314)
at com.sun.faces.config.processor.FaceletTaglibConfigProcessor.process(FaceletTaglibConfigProcessor.java:263)
at com.sun.faces.config.ConfigManager.initialize(ConfigManager.java:362)
at com.sun.faces.config.ConfigureListener.contextInitialized(ConfigureListener.java:225)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4971)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5467)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
at java.util.concurrent.FutureTask.run(FutureTask.java:138)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:619)
Caused by: java.lang.ClassNotFoundException: org.springframework.faces.security.FaceletsAuthorizeTagHandler
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1720)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1571)
at com.sun.faces.util.Util.loadClass(Util.java:293)
at com.sun.faces.config.processor.AbstractConfigProcessor.loadClass(AbstractConfigProcessor.java:311)
at com.sun.faces.config.processor.FaceletTaglibConfigProcessor.processHandlerClass(FaceletTaglibConfigProcessor.java:420)
... 15 more
25 mai 2014 15:29:06 org.apache.catalina.core.StandardContext listenerStart
GRAVE: Exception lors de l'envoi de l'évènement contexte initialisé (context initialized) à l'instance de classe d'écoute (listener) com.sun.faces.config.ConfigureListener
java.lang.RuntimeException: com.sun.faces.config.ConfigurationException: java.lang.ClassNotFoundException: org.springframework.faces.security.FaceletsAuthorizeTagHandler
at com.sun.faces.config.ConfigureListener.contextInitialized(ConfigureListener.java:292)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4971)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5467)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
at java.util.concurrent.FutureTask.run(FutureTask.java:138)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:619)
Caused by: com.sun.faces.config.ConfigurationException: java.lang.ClassNotFoundException: org.springframework.faces.security.FaceletsAuthorizeTagHandler
at com.sun.faces.config.processor.FaceletTaglibConfigProcessor.processHandlerClass(FaceletTaglibConfigProcessor.java:436)
at com.sun.faces.config.processor.FaceletTaglibConfigProcessor.processTags(FaceletTaglibConfigProcessor.java:371)
at com.sun.faces.config.processor.FaceletTaglibConfigProcessor.processTagLibrary(FaceletTaglibConfigProcessor.java:314)
at com.sun.faces.config.processor.FaceletTaglibConfigProcessor.process(FaceletTaglibConfigProcessor.java:263)
at com.sun.faces.config.ConfigManager.initialize(ConfigManager.java:362)
at com.sun.faces.config.ConfigureListener.contextInitialized(ConfigureListener.java:225)
... 10 more
Caused by: java.lang.ClassNotFoundException: org.springframework.faces.security.FaceletsAuthorizeTagHandler
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1720)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1571)
at com.sun.faces.util.Util.loadClass(Util.java:293)
at com.sun.faces.config.processor.AbstractConfigProcessor.loadClass(AbstractConfigProcessor.java:311)
at com.sun.faces.config.processor.FaceletTaglibConfigProcessor.processHandlerClass(FaceletTaglibConfigProcessor.java:420)
... 15 more

this errors required the add of spring-faces and if i add this library he intercept the jsf url parameters like (http://localhost:8080/projet/etudiant.jsf?idEtudiant=2

you understand the problem now or not ??

Denis Kniazhev

unread,
May 25, 2014, 10:53:23 AM5/25/14
to spring-secu...@googlegroups.com
Can you clearly define what "jsf url parametred no longer works" mean? What exactly doesn't work? Reading a parameter returns nothing? -- If so, how do you pass it and how are you trying to read it? Passing a parameter gives an exception? -- If so, what's the stacktrace? And I strongly recommend to omit phrases such as "I need help urgent" and "you understand the problem now or not??" if you expect that someone will spend his personal time to help you with your problem.


--
Message has been deleted

Dominik Dorn

unread,
May 25, 2014, 11:39:31 AM5/25/14
to spring-secu...@googlegroups.com
Andree, either use this the library as in the example projects or use the new spring library the way they show it.. but don't mix it up - it will not work. 

you can find a working example of jsf 2.0 and spring 3 here:

I'm not sure if this works with recent versions of spring or JSF as I don't use either anymore.. but the code isn't hard to read. 




On Sun, May 25, 2014 at 5:07 PM, Andree Tago <andre...@gmail.com> wrote:
my example is describe here 
i have the firts jsf page called index.xhtml in this  file i have this code :


 <h:form prependId="false" style="margin-top:25px">

<p:dataTable id="dataTable" var="lot"
value="#{lotissementBean.getAllLotissement()}" paginator="true"
rows="5"
paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}">
<f:facet name="header">  
            Liste des lotissements  
        </f:facet>

<p:column>
<f:facet name="header">
<h:outputText value="Designation" />
</f:facet>
<h:outputText value="#{lot.nom}" />
</p:column>

<p:column>
<f:facet name="header">
<h:outputText value="Description" />
</f:facet>
<h:outputText value="#{lot.description}" />
</p:column>
                         <p:column style="width:4%">
<f:facet name="header">
<h:outputText value="Etude" />
</f:facet>
<p:button id="updateButton" icon="ui-icon-update" outcome="etude_new">
<f:param name="lotissementIdEtude" value="#{lot.idLotissement}" />

</p:button>

</p:column>
                         </p:dataTable>

</h:form>


and the second file is etude_new.xhtml it contain the following code :

<f:metadata>
<f:viewParam name="lotissementIdEtude"
value="#{etudeBean.lotissementIdEtude}" />
</f:metadata>

<h:form prependId="false" style="margin-top:25px" id="formTable">

<p:dataTable id="dataTable" var="etude"
value="#{etudeBean.getAllLotissement()}" paginator="true" rows="15"
paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}">
<f:facet name="header">  
            Liste des Etudes Lotissement: #{etudeBean.trouverLotissement().nom}
        </f:facet>

<p:column>
<f:facet name="header">
<h:outputText value="Designation" />
</f:facet>
<h:outputText value="#{etude.designation}" />
</p:column>

<p:column>
<f:facet name="header">
<h:outputText value="Description" />
</f:facet>
<h:outputText value="#{etude.description}" />
</p:column>

             </p:dataTable>

</h:form>


when i select a row from the first page (index.xhtml) and i clik on the update button i was rederect to the etude_new.xhtml ( http://localhost:8080/projet/etude_new?lotissementIdEtude=2) the problem is the parameter lotissementIdEtude still null no value with the spring-faces but when i remove this library the solution work 

--

---
You received this message because you are subscribed to the Google Groups "Spring Security Facelets-JSF 2.0-taglib" group.
To unsubscribe from this group and stop receiving emails from it, send an email to spring-security-t...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Andree Tago

unread,
May 25, 2014, 11:54:01 AM5/25/14
to spring-secu...@googlegroups.com
u still not understand what i want exactly ok thank's fir you i will find the soolution alone

Dominik Dorn

unread,
May 25, 2014, 12:14:38 PM5/25/14
to spring-secu...@googlegroups.com
i do understand... your view-param is null with "a library" attached... however, we don't know if its null with this library or the one provided with spring... we don't know which application server you're running, which jsf version etc. 
if you're willing to setup a test-project with maven so we can reproduce the error, we might be able to help you.
From your explanation so far, it probably needs a phaselistener somewhere or an adjustment to one of springs filters. 

if you want to do that, simply clone the source repository and adjust the example project to your needs so we can reproduce the error. 





On Sun, May 25, 2014 at 5:54 PM, Andree Tago <andre...@gmail.com> wrote:
u still not understand what i want exactly ok thank's fir you i will find the soolution alone

--

---
You received this message because you are subscribed to the Google Groups "Spring Security Facelets-JSF 2.0-taglib" group.
To unsubscribe from this group and stop receiving emails from it, send an email to spring-security-t...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Andree Tago

unread,
May 25, 2014, 2:43:35 PM5/25/14
to spring-secu...@googlegroups.com
thank's i resolve the probleme merci chokran
 

Dominik Dorn

unread,
May 25, 2014, 3:12:50 PM5/25/14
to spring-secu...@googlegroups.com
would you mind sharing your solution, so if others have the same problem, they can read here how to fix it? 

thanks,
dominik


On Sun, May 25, 2014 at 8:43 PM, Andree Tago <andre...@gmail.com> wrote:
thank's i resolve the probleme merci chokran
 

--

---
You received this message because you are subscribed to the Google Groups "Spring Security Facelets-JSF 2.0-taglib" group.
To unsubscribe from this group and stop receiving emails from it, send an email to spring-security-t...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

zeineb yahyaoui

unread,
Jun 18, 2014, 6:41:52 AM6/18/14
to spring-secu...@googlegroups.com
Bonjour,
I have the same problem. Can you please share your Solution.
Thank You
Reply all
Reply to author
Forward
0 new messages