Am trying to create a composite component that will display the values as overlaypanel. But it returns the below error;
Cannot find component 'j_idt58:reviewDataTable:0:overrideCol' in view
overrideVersionDetails.xhtml:(composite component)
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:cc="http://java.sun.com/jsf/composite"
xmlns:p="http://primefaces.org/ui"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:fn="http://java.sun.com/jsp/jstl/functions"
xmlns:c="http://java.sun.com/jsp/jstl/core">
<cc:interface>
<cc:attribute name="forId" type="java.lang.String" required="true" />
<cc:attribute name="forValue" type="java.lang.Object" />
</cc:interface>
<cc:implementation>
<p:overlayPanel for="#{cc.attrs.forId}" my="left bottom">
#{cc.attrs.forValue}
</p:overlayPanel>
</cc:implementation>
</ui:composition>
Its used in another page:
<h:form>
....
...
<p:dataTable .....>
....
<p:column sortBy="#{dto.isSameCycleOverride}" width="100">
<f:facet name="header">
Override
</f:facet>
<h:commandLink id="overrideCol" binding="#{overrideCol}"
value="#{(dto.isSameCycleOverride) ? 'Yes' : 'No'}" />
<comp:overrideVersionDetails forId="#{overrideCol.clientId}"
forValue="#{dto.message}" />
</p:column>
....
</p:dataTable>
</h:form>
Any help is really appreciated.
I don't work with Primefaces, but with RichFaces I would use :
<comp:overrideVersionDetails forId="#{rich:clientId('overrideCol')}"
forValue="#{dto.message}" />
to do what you want.
With a little Help from SO :
Rich Faces rich:clientId in Primefaces?
it seems you can do this :
...
<h:commandLink id="overrideCol" value="#{(dto.isSameCycleOverride) ? 'Yes' : 'No'}" />
<comp:overrideVersionDetails forId="#{p:component('overrideCol')}"
forValue="#{dto.message}" />
...
Now to see if this works better than the use of binding in a dataTable...
Related
I'm trying to integrate Spring Security inside ui:composition.
I'm getting help from this helpful link : https://raichand-java.blogspot.in/2016/12/springsecurity4primefaces5springdatajpa.html
It works as well.
But, after integrating the code inside ui:composition, I got an exception.
Knowing that I added the file 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>
I added to the file web.xml:
<context-param>
<param-name>javax.faces.FACELETS_LIBRARIES</param-name>
<param-value>/WEB-INF/springsecurity.taglib.xml</param-value>
</context-param>
After running this page:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:c="http://java.sun.com/jsp/jstl/core"
xmlns:p="http://primefaces.org/ui">
<h:head>
<title>Login</title>
<h:outputScript library="primefaces" name="jquery/jquery.js"
target="head" />
<h:outputScript library="primefaces" name="jquery/jquery-plugins.js"
target="head" />
</h:head>
<h:body>
<ui:composition template="/templates/homeTemplate.xhtml"
xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:sec="http://www.springframework.org/security/tags"
xmlns:p="http://primefaces.org/ui">
<ui:define name="content">
<center><h2>Login</h2></center>
<c:if test="${'fail' eq param.auth}">
<div style="color:red">
Login Failed!!!<br/>
Reason : Bad Credentials!Please Try Again.
</div>
</c:if>
<center>
<h:form prependId="false" id="form">
<p:panelGrid columns="2" style="border-bottom-width: 0px;">
<h:outputText value="UserName:"/>
<p:inputText value="#{loginController.username}" id="username" required="true" requiredMessage="UserName is required"/>
<h:outputText value="Password:"/>
<p:password value="#{loginController.password}" id="password" required="true" requiredMessage="Password is required"/>
</p:panelGrid>
<p:spacer height="20px" width="10px"> </p:spacer>
<p:row>
<p:selectBooleanCheckbox label="Remember Me" id="remember-me" >Remember Me </p:selectBooleanCheckbox>
<h:outputText value=" " />
</p:row>
<br/>
<p:row>
<p:commandButton action="#{loginController.login()}" value="Login" ajax="false"/>
</p:row>
</h:form>
</center>
</ui:define>
</ui:composition>
</h:body>
</html>
I got this exception:
SEVERE [javax.enterprise.resource.webcontainer.jsf.config] (ServerService Thread Pool -- 175) Critical error during deployment: : com.sun.faces.config.ConfigurationException: CONFIGURATION FAILED! org.springframework.faces.security.FaceletsAuthorizeTagHandler from [Module "deployment.mission-man-ear.ear.mission-man-web.war:main" from Service Module Loader]
at com.sun.faces.config.ConfigManager.initialize(ConfigManager.java:453)
at com.sun.faces.config.ConfigureListener.contextInitialized(ConfigureListener.java:227)
at io.undertow.servlet.core.ApplicationListeners.contextInitialized(ApplicationListeners.java:187)
at io.undertow.servlet.core.DeploymentManagerImpl.deploy(DeploymentManagerImpl.java:198)
at org.wildfly.extension.undertow.deployment.UndertowDeploymentService.startContext(UndertowDeploymentService.java:100)
at org.wildfly.extension.undertow.deployment.UndertowDeploymentService$1.run(UndertowDeploymentService.java:82)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:748)
at org.jboss.threads.JBossThread.run(JBossThread.java:320)
After googling, I found this thread java.lang.ClassNotFoundException: org.springframework.faces.security.FaceletsAuthorizeTagHandler, but didn't help me!. I think that there's a problem of version of spring-security-taglibs dependency version. Have you please any idea about solving this. Any help is appreciated. Thanks a lot.
I's no need to make the new changes.
Try Run As> Maven Clean, Run As> Maven Install then Maven> Update Project.
That's all.
HTH
im using jsf 2.2 majorra and primefaces 5.1 to build a webapp
i know this has probably been answered before, but i dont find my error... i took examples from the primefaces showcase and tried some stuff suggested by the internet, but it doesnt want to work
<?xml version="1.0" encoding="UTF-8"?>
<ui:composition template="/WEB-INF/template/master.xhtml"
xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:p="http://primefaces.org/ui"
xmlns:pe="http://primefaces.org/ui/extensions"
xmlns:ui="http://xmlns.jcp.org/jsf/facelets">
<ui:define name="content">
<p:selectManyMenu id="userList"
value="#{userAdministrationController.selectedUsers}" var="t"
filter="true" filterMatchMode="contains" showCheckbox="true">
<f:selectItems value="#{userAdministrationController.selectItemList}"
var="user" itemLabel="#{user.fullName}" itemValue="#{user}" />
<p:column>
<h:outputText value="#{t}" />
</p:column>
</p:selectManyMenu>
<p:separator />
<p:commandButton value="Submit" oncomplete="PF('dlg').show()"
icon="ui-icon-check" />
</ui:define>
</ui:composition>
im trying to load this list so that some users are already selected when visiting the page, like a default value
all users show as desired, but no default values are loaded to the checkboxes
thanks in advance
okay now i found the answer:
working code->
<p:selectManyMenu id="userList"
value="#{userAdministrationController.selectedUsers}" var="t"
filter="true" filterMatchMode="contains" showCheckbox="true" >
<f:selectItems value="#{userAdministrationController.selectItemList}"
var="user" itemValue="#{user}" />
<p:column>
<h:outputText value="#{t}" />
</p:column>
</p:selectManyMenu>
without the converter! and in my bean i had to make a List for the preselected values, the stuff in the list has to be the same type as the VALUES of the selectitems
List<User> inactiveUsers = userService.findByActive(false);
List<User> userList = userService.findAll();
selectItemList = new ArrayList<SelectItem>();
for (User user : userList) {
SelectItem selectItem = new SelectItem(user.getFullName(), WordUtils.capitalize(user.getFullName()));
selectItemList.add(selectItem);
}
selectedUsers = new ArrayList<String>();
for (User user : inactiveUsers) {
String userName = user.getFullName();
selectedUsers.add(userName);
}
I want to rewrite part of the code using composite component.
I need to instead this:
<ui:fragment rendered="#{!empty param.vid}">
<h:link outcome="index" value="#{msgs.vendor_tabmenu_profile}"
styleClass="#{(param.pg == 'profile') ? 'selected' : ''}">
<f:param name="pg" value="profile"/>
<f:param name="vid" value="#{param.vid}"/>
</h:link>
<h:link outcome="index" value="#{msgs.vendor_tabmenu_orders}"
styleClass="#{(param.pg == 'orders') ? 'selected' : ''}">
<f:param name="pg" value="orders"/>
<f:param name="vid" value="#{param.vid}"/>
</h:link>
....
somethink like this:
<components:vmtab outPage="index"
value="#{msgs.vendor_tabmenu_search}"
withParam="false"
pg=""
vid=""
selectedClass="#{( (empty param.pg) ||
(param.pg == 'search') ||
(param.pg == 'index') ) ? 'selected' : ''}"
/>
with:
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://xmlns.jcp.org/jsf/core"
xmlns:composite="http://java.sun.com/jsf/composite">
<composite:interface>
<composite:attribute name="outPage" required="true"/>
<composite:attribute name="withParam" required="true"/>
<composite:attribute name="pg" required="true"/>
<composite:attribute name="vid" required="true"/>
<composite:attribute name="value" required="true"/>
<composite:attribute name="selectedClass" />
<composite:attribute name="styleClass" />
</composite:interface>
<composite:implementation>
<h:link
outcome="#{composite.attrs.outPage}"
value="#{composite.attrs.value}"
styleClass="#{''.concat((!empty composite.attrs.styleClass ? composite.attrs.styleClass : '')).concat(
(!empty composite.attrs.selectedClass ? composite.attrs.selectedClass : ''))}"
>
<f:param name="pg" value="#{composite.attrs.pg}"
rendered="#{composite.attrs.withParam}"/>
<f:param name="vid" value="#{composite.attrs.vid}"
rendered="#{composite.attrs.withParam}"/>
</h:link>
</composite:implementation>
</html>
But i have a trouble. JSF says me:
This link is disabled because a navigation case could not be matched
Please explain what I'm doing wrong.
UPD:
Thanks for your attention. Sorry. Found the problem. The root of evil, as often happens, inattention. I thought that if I wrote in XML composite namespace I had to use it. But the EL is used object named cc.
PS: I dont know how to close or delete.. or what should I do with this question ?
I created a tagfile for a confirm dialog with a command button:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:c="http://java.sun.com/jsp/jstl/core"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:p="http://primefaces.org/ui"
xmlns:a4j="http://richfaces.org/a4j"
xmlns:aym="http://aym.com/facelets"
xmlns:rich="http://richfaces.org/rich"
>
<h:body>
<ui:composition>
<p:growl id="messages" />
<h:panelGrid columns="1" cellpadding="5">
<p:commandButton value="#{label}" onclick="#{pupupId}.show()" type="button" ajax="false"/>
</h:panelGrid>
<p:confirmDialog message="#{message}"
showEffect="bounce" hideEffect="explode"
header="İşlem Onay" severity="alert" widgetVar="#{pupupId}">
<p:commandButton value="Evet" update="messages" oncomplete="#{pupupId}.hide()" ajax="false"
action="#{actionMethod}" />
<p:commandButton value="Hayır" onclick="#{pupupId}.hide()" type="button" />
</p:confirmDialog>
</ui:composition>
</h:body>
</html>
Here's how I'm using it:
<aym:onayButon id="onay2" label="#{lbl.kaydet}"
actionMethod="#{userMB.addUser}" pupupId="onaylaPopup"
message="#{msg.onay_sonuc}" />
I am passing the action method that I am going to call when I click the button. However, when I do that, then I am getting a PropertyNotFoundException:
WARNING: #{actionMethod}: javax.el.PropertyNotFoundException: /WEB-INF/tags/com/components/onayButton.xhtml #29,33 action="#{actionMethod}": /pages/index.xhtml #33,48 actionMethod="#{userMB.addUser}": Property 'addUser' not found on type com.otv.managed.bean.UserManagedBean
javax.faces.FacesException: #{actionMethod}: javax.el.PropertyNotFoundException: /WEB-INF/tags/com/components/onayButton.xhtml #29,33 action="#{actionMethod}": /pages/index.xhtml #33,48 actionMethod="#{userMB.addUser}": Property 'addUser' not found on type com.otv.managed.bean.UserManagedBean
at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:118)
It works fine when I hardcode the action method in the tagfile like so:
<p:commandButton ... action="#{userMB.addUser}" />
How is this caused and how can I solve it?
Try as a workaround to give action bean and action method as two separate parameters:
Template
<p:commandButton value="Evet"
update="messages" oncomplete="#{pupupId}.hide()" ajax="false"
action="#{actionBean[actionMethod]}" />
call
<aym:onayButon id="onay2" label="#{lbl.kaydet}"
actionBean="#{userMB}" actionMethod="addUser" pupupId="onaylaPopup"
message="#{msg.onay_sonuc}" />
On the call, the bean needs to be in curly brackets, the method name is only given as string. See also Solution on a similar topic .
Maybe it helps...
This is the Facelet:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns ="http://www.w3.org/1999/xhtml" xmlns:h="http://java.sun.com/jsf/html">
<h:head>
<title>Title</title>
</h:head>
<h:body>
<h:form>
<h:commandButton value ="Converter" action ="#{conversorMonetarioBean.converte}"/>
<h:inputText value ="#{conversorMonetarioBean.valor}"/>
<h:outputLabel value ="de" for ="de"/>
<h:selectOneMenu value ="#{conversorMonetarioBean.de}" id="de">
<f:selectItems
value ="#{conversorMonetarioBean.taxas.keySet()}"
var ="moeda"
itemValue ="#{moeda}"
itemLabel ="#{moeda}" />
</h:selectOneMenu>
<h:outputLabel value ="para" for ="para"/>
<h:selectOneMenu value ="#{conversorMonetarioBean.para}" id="para">
<f:selectItems
value ="#{conversorMonetarioBean.taxas.keySet()}"
var ="moeda"
itemValue ="#{moeda}"
itemLabel ="#{moeda}" />
</h:selectOneMenu>
</h:form>
<h:outputFormat value ="{0} em {1} equivale a {2} em {3}" rendered ="#{conversorMonetarioBean.resultado != null}">
<f:param value ="#{conversorMonetarioBean.valor}"/>
<f:param value ="#{conversorMonetarioBean.de}"/>
<f:param value ="#{conversorMonetarioBean.resultado}"/>
<f:param value ="#{conversorMonetarioBean.para}"/>
</h:outputFormat>
</h:body>
</html>
It's saying that f:selectItems is an unknown tag.
What could be wrong ? I'm using JSF2, GlassFish 3.1.2, Eclipse. I tried to ctrl+space and only have h:something tags.
You forgot to import f namespace in your html declaration, xmlns:f="http://java.sun.com/jsf/core", so that the top section will be like:
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core">
Also, your IDE is possibly showing you a hint that f namespace is missing, so following its instructions to do the import will solve your problem.