I get the following exception when I click a button on a JSF/RichFaces page.
This problem only seems to happen on one server. Any ideas?
StandardWrapperValve[Faces Servlet]: PWC1406: Servlet.service() for servlet Faces Servlet threw exception
java.lang.NullPointerException
at com.sun.faces.renderkit.html_basic.MenuRenderer.getCurrentSelectedValues(MenuRenderer.java:633)
at com.sun.faces.renderkit.html_basic.MenuRenderer.renderOption(MenuRenderer.java:524)
at com.sun.faces.renderkit.html_basic.MenuRenderer.renderOptions(MenuRenderer.java:757)
at com.sun.faces.renderkit.html_basic.MenuRenderer.renderSelect(MenuRenderer.java:811)
at com.sun.faces.renderkit.html_basic.MenuRenderer.encodeEnd(MenuRenderer.java:335)
at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:836)
at com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.encodeRecursive(HtmlBasicRenderer.java:279)
at com.sun.faces.renderkit.html_basic.GridRenderer.encodeChildren(GridRenderer.java:242)
at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:812)
at com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.encodeRecursive(HtmlBasicRenderer.java:271)
at com.sun.faces.renderkit.html_basic.GridRenderer.encodeChildren(GridRenderer.java:242)
at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:812)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:886)
at javax.faces.render.Renderer.encodeChildren(Renderer.java:137)
at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:812)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:886)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:892)
at com.sun.faces.application.ViewHandlerImpl.doRenderView(ViewHandlerImpl.java:245)
at com.sun.faces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:176)
at org.ajax4jsf.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:100)
at org.ajax4jsf.application.AjaxViewHandler.renderView(AjaxViewHandler.java:176)
at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:106)
at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:251)
at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:144)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:245)
at org.apache.catalina.core.ApplicationFilterChain.servletService(ApplicationFilterChain.java:427)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:333)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:214)
at org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:178)
at org.ajax4jsf.webapp.BaseFilter.handleRequest(BaseFilter.java:290)
at org.ajax4jsf.webapp.BaseFilter.processUploadsAndHandleRequest(BaseFilter.java:368)
at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:495)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:246)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:214)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:313)
at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:287)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:218)
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:648)
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:593)
at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:94)
at com.sun.enterprise.web.PESessionLockingStandardPipeline.invoke(PESessionLockingStandardPipeline.java:98)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:222)
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:648)
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:593)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:587)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:1096)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:166)
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:648)
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:593)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:587)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:1096)
at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:288)
at com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.invokeAdapter(DefaultProcessorTask.java:647)
at com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.doProcess(DefaultProcessorTask.java:579)
at com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.process(DefaultProcessorTask.java:831)
at com.sun.enterprise.web.connector.grizzly.DefaultReadTask.executeProcessorTask(DefaultReadTask.java:341)
at com.sun.enterprise.web.connector.grizzly.DefaultReadTask.doTask(DefaultReadTask.java:263)
at com.sun.enterprise.web.connector.grizzly.DefaultReadTask.doTask(DefaultReadTask.java:214)
at com.sun.enterprise.web.connector.grizzly.TaskBase.run(TaskBase.java:265)
at com.sun.enterprise.web.connector.grizzly.ssl.SSLWorkerThread.run(SSLWorkerThread.java:106)
here's the page causing the problem:
<h:form id="clientCreatorForm" >
<h1><h:outputText value="Linguist Creator"/></h1>
<rich:messages styleClass="error_msg" showDetail="true" showSummary="true"/>
<h:panelGrid id="op" columns="2">
<rich:spacer height="20px" />
<h:outputText value="" />
<h:outputText value="Linguists:" />
<rich:comboBox value="#{linguistCreator.linguistCompanyName}">
<f:selectItems value="#{linguistCreator.companyItemsAvailable}" />
<a4j:support action="#{linguistCreator.l1RequiredInputTest}"
ajaxSingle="true"
event="onselect"
reRender="footerPanel" />
</rich:comboBox>
</h:panelGrid>
<rich:spacer height="20px" />
<h:panelGrid id="footerPanel" columns="1" >
<a4j:commandButton id="updatebutton" value="Add new Language(s) to selected linguist."
action="#{linguistCreator.retrieveLinguistObjects}"
disabled="#{linguistCreator.enterDisabledL1}"/>
<a4j:commandButton id="addButton" value="Add new linguist" action="linguist2" />
</h:panelGrid>
</h:form>
Related
I have one template.xhtml file at /template/template.xhtml
<h:head>
</h:head>
<h:body>
<p:layout fullPage="true">
<p:layoutUnit position="north" size="100">
<h:outputText value="header"></h:outputText>
</p:layoutUnit>
<p:layoutUnit position="center">
<p:layout>
<p:layoutUnit position="north">
<h:outputText value="tabs"/>
<ui:include src="/tabs/tabs.xhtml"/>
</p:layoutUnit>
<p:layoutUnit position="west">
<h:outputText value="left menu"></h:outputText>
</p:layoutUnit>
<p:layoutUnit position="center">
<h:outputText value="main-content"></h:outputText>
</p:layoutUnit>
</p:layout>
</p:layoutUnit>
<p:layoutUnit position="south" size="100">
<h:outputText value="footer"></h:outputText>
</p:layoutUnit>
</p:layout>
</h:body>
</html>
I have tabs.xhtml file at /tabs/tabs.xhtml
<h:head>
</h:head>
<p:tabMenu activeIndex="#{param.i}">
<p:menuitem value="Overview" outcome="index">
<f:param name="i" value="0" />
</p:menuitem>
<p:menuitem value="Demos" outcome="index">
<f:param name="i" value="1" />
</p:menuitem>
<p:menuitem value="Documentation" outcome="index">
<f:param name="i" value="2" />
</p:menuitem>
<p:menuitem value="Support" outcome="index">
<f:param name="i" value="3" />
</p:menuitem>
<p:menuitem value="Social" outcome="index">
<f:param name="i" value="4" />
</p:menuitem>
</p:tabMenu>
I am getting the following exception because of the ui include tag in template.xhtml. Is the src attribute of ui include is wrong.:
javax.faces.FacesException: Could not resolve NavigationCase for outcome: index
at org.primefaces.renderkit.OutcomeTargetRenderer.getTargetURL(OutcomeTargetRenderer.java:86)
at org.primefaces.component.menu.BaseMenuRenderer.encodeMenuItem(BaseMenuRenderer.java:162)
at org.primefaces.component.tabmenu.TabMenuRenderer.encodeItem(TabMenuRenderer.java:89)
at org.primefaces.component.tabmenu.TabMenuRenderer.encodeMarkup(TabMenuRenderer.java:65)
at org.primefaces.component.menu.BaseMenuRenderer.encodeEnd(BaseMenuRenderer.java:108)
at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:879)
at org.primefaces.renderkit.CoreRenderer.renderChild(CoreRenderer.java:85)
at org.primefaces.renderkit.CoreRenderer.renderChildren(CoreRenderer.java:68)
at org.primefaces.component.layout.LayoutUnitRenderer.encodeEnd(LayoutUnitRenderer.java:49)
at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:879)
at org.primefaces.renderkit.CoreRenderer.renderChild(CoreRenderer.java:85)
at org.primefaces.renderkit.CoreRenderer.renderChildren(CoreRenderer.java:68)
at org.primefaces.renderkit.CoreRenderer.renderChild(CoreRenderer.java:83)
at org.primefaces.renderkit.CoreRenderer.renderChildren(CoreRenderer.java:68)
at org.primefaces.component.layout.LayoutUnitRenderer.encodeEnd(LayoutUnitRenderer.java:49)
at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:879)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1655)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1651)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1651)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1651)
at com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:395)
at com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:127)
at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:117)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:97)
at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:135)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:309)
at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227)
at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125)
at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:301)
at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:26)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
at weblogic.servlet.internal.RequestEventsFilter.doFilter(RequestEventsFilter.java:27)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.wrapRun(WebAppServletContext.java:3730)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3696)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:120)
at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2273)
at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2179)
at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1490)
at weblogic.work.ExecuteThread.execute(ExecuteThread.java:256)
at weblogic.work.ExecuteThread.run(ExecuteThread.java:221)
The ui:include tag is working as expected. The problem is inside tabx.xhtml. For the menuitems your have outcome="index" and my money is on the index.xhtml not in the same folder as tab.xhtml. Either make sure the outcome is a relative link like ../index or make it absolute like /index.
For further assistance you should post your directory structure.
Consider the following Primefaces 5.3 JSF code fragment:
<p:column sortBy="#{benutzer.emailAdresse}" headerText="#{res.com_lbl_column_header_email}"
filterBy="#{benutzer.emailAdresse}" filterStyle="margin-top:5px;" filterPosition="bottom" filterOptions="contains">
<f:facet name="filter">
<p:autoComplete id="dynaEmail" dropdown="true" inputStyleClass="inputFilterM" queryDelay="300"
value="#{benutzerListBean.dyna_search_email}" completeMethod="#{benutzerListBean.completeTextEmail}"
style="margin-left:10px;" cache="false" onchange="PF('tblBenutzer').filter()">
<p:ajax event="keyup" update="dynaVorname, dynaNachname" listener="#{benutzerListBean.dynaSearchStringValueChanged}" />
<p:ajax event="itemSelect" update="dynaVorname, dynaNachname"
listener="#{benutzerListBean.dynaSearchStringValueChanged}" />
</p:autoComplete>
<p:commandButton icon="ui-icon-trash" style="margin-left:35px;">
<f:param name="sender" value="dyna_search_email" />
<p:ajax event="click" update="tblBenutzer, dynaEmail" listener="#{benutzerListBean.resetCurrentFilter}" />
</p:commandButton>
</f:facet>
<h:outputText value="#{benutzer.emailAdresse}" />
</p:column>
So autocomplete in filter.The autocomplete dropdown menu works perfectly, but as I type something in I have a strange exception:
2015-12-21 19:08:30,739 INFO [javax.enterprise.resource.webcontainer.jsf.context] (http-/0.0.0.0:8443-5) java.lang.ClassCastException: javax.faces.component.UIPanel cannot be cast to javax.faces.component.ValueHolder: java.lang.ClassCastException: javax.faces.component.UIPanel cannot be cast to javax.faces.component.ValueHolder
at org.primefaces.component.datatable.feature.FilterFeature.populateFilterMetaDataWithoutColumnGroups(FilterFeature.java:346) [primefaces-5.3.jar:5.3]
at org.primefaces.component.datatable.feature.FilterFeature.populateFilterMetaData(FilterFeature.java:259) [primefaces-5.3.jar:5.3]
at org.primefaces.component.datatable.feature.FilterFeature.decode(FilterFeature.java:90) [primefaces-5.3.jar:5.3]
at org.primefaces.component.datatable.DataTable.processValidators(DataTable.java:716) [primefaces-5.3.jar:5.3]
at com.sun.faces.context.PartialViewContextImpl$PhaseAwareVisitCallback.visit(PartialViewContextImpl.java:575) [jsf-impl-2.2.12.jar:2.2.12]
at com.sun.faces.component.visit.PartialVisitContext.invokeVisitCallback(PartialVisitContext.java:183) [jsf-impl-2.2.12.jar:2.2.12]
at org.primefaces.component.api.UIData.visitTree(UIData.java:822) [primefaces-5.3.jar:5.3]
I've tried to move the code to "header" facet, and it worked.. but this way the sorting works weard.
How can I fix the exception?
I followed the DataTable Filter showcase from PrimeFaces on my own DataTable. Every time the "onkeyup" event occurs I get a
TypeError: PF(...) is undefined error in Firebug and a "Uncaught
TypeError: Cannot read property 'filter' of undefined
in Chrome Console. The filtering does not work.
Here is my XHTML page:
<?xml version="1.0" encoding="UTF-8"?>
<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:p="http://primefaces.org/ui">
<h:head>
<h:title>List of User</h:title>
</h:head>
<h:body>
<h:form id="UserForm" name="UserRecords">
<p:dataTable id="users" widgetVar="usersTable" var="user" value="#{userBean.users}" scrollable="false" frozenColumns="0" sortMode="multiple" stickyHeader="true" filteredValue="#{userBean.filteredUsers}">
<f:facet name="header">User<p:inputText id="globalFilter" onkeyup="PF('usersTable').filter()" style="float:right" placeholder="Filter"/>
<p:commandButton id="toggler" type="button" style="float:right" value="Columns" icon="ui-icon-calculator"/>
<p:columnToggler datasource="users" trigger="toggler"/>
<p:commandButton id="optionsButton" value="Options" type="button" style="float:right"/>
<p:menu overlay="true" trigger="optionsButton" my="left top" at="left bottom">
<p:submenu label="Export">
<p:menuitem value="XLS">
<p:dataExporter type="xls" target="users" fileName="users"/>
</p:menuitem>
<p:menuitem value="PDF">
<p:dataExporter type="pdf" target="users" fileName="users"/>
</p:menuitem>
<p:menuitem value="CSV">
<p:dataExporter type="csv" target="users" fileName="users"/>
</p:menuitem>
<p:menuitem value="XML">
<p:dataExporter type="xml" target="users" fileName="users"/>
</p:menuitem>
</p:submenu>
</p:menu>
</f:facet>
<p:column disabledSection="false" colspan="1" exportable="true" filterBy="#{user.firstName}" filterMatchMode="startsWith" filterStyle="display:none; visibility:hidden;" filterable="true" headerText="FirstName" priority="0" rendered="true" resizable="true" rowspan="1" selectRow="true" sortable="true" toggleable="true" visible="true">
<h:outputText value="#{user.firstName}"/>
</p:column>
<p:column disabledSection="false" colspan="1" exportable="true" filterBy="#{user.lastName}" filterMatchMode="startsWith" filterStyle="display:none; visibility:hidden;" filterable="true" headerText="LastName" priority="0" rendered="true" resizable="true" rowspan="1" selectRow="true" sortable="true" toggleable="true" visible="true">
<h:outputText value="#{user.lastName}"/>
</p:column>
<p:column disabledSection="false" colspan="1" exportable="true" filterBy="#{user.username}" filterMatchMode="startsWith" filterStyle="display:none; visibility:hidden;" filterable="true" headerText="Username" priority="0" rendered="true" resizable="true" rowspan="1" selectRow="true" sortable="true" toggleable="true" visible="true">
<h:outputText value="#{user.username}"/>
</p:column>
<p:column disabledSection="false" colspan="1" exportable="true" filterBy="#{user.password}" filterMatchMode="startsWith" filterStyle="display:none; visibility:hidden;" filterable="true" headerText="Password" priority="0" rendered="true" resizable="true" rowspan="1" selectRow="true" sortable="true" toggleable="true" visible="true">
<h:outputText value="#{user.password}"/>
</p:column>
<p:column disabledSection="false" colspan="1" exportable="true" filterBy="#{user.id}" filterMatchMode="startsWith" filterStyle="display:none; visibility:hidden;" filterable="true" headerText="Id" priority="0" rendered="true" resizable="true" rowspan="1" selectRow="true" sortable="true" toggleable="true" visible="true">
<h:outputText value="#{user.id}"/>
</p:column>
<p:column disabledSection="false" colspan="1" exportable="true" filterBy="#{user.createdOn}" filterMatchMode="startsWith" filterStyle="display:none; visibility:hidden;" filterable="true" headerText="CreatedOn" priority="0" rendered="true" resizable="true" rowspan="1" selectRow="true" sortable="true" toggleable="true" visible="true">
<h:outputText value="#{user.createdOn}"/>
</p:column>
<p:column disabledSection="false" colspan="1" exportable="true" filterBy="#{user.lastModified}" filterMatchMode="startsWith" filterStyle="display:none; visibility:hidden;" filterable="true" headerText="LastModified" priority="0" rendered="true" resizable="true" rowspan="1" selectRow="true" sortable="true" toggleable="true" visible="true">
<h:outputText value="#{user.lastModified}"/>
</p:column>
</p:dataTable>
</h:form>
</h:body>
</html>
I'm using PrimeFaces 5.2 with Mojarra 2.2.8 and JSF 2.2.10.
In my case, I found that my TypeError: PF(...) is undefined error (without the additional property error) was caused by Primefaces not being able to find the widget widgetVar="usersTable" for example because of a spelling error
In this case, the console output right above the error in Firebug gives you the explanation Widget for var 'editExecContactDialogg' not available!
That can happen when the runtime classpath is dirty of duplicate different versioned libraries. Conflicts would then occur during class loading and resource resolving.
Make sure that you're using only one version of a library. This not only applies to PrimeFaces, but also to Mojarra. Having both 2.2.8 and 2.2.10 is definitely not right.
Like #hendinas' answer, this is not the solution to the particular problem, but might be helpful for future Googlers that have the exact same error but with a different cause.
This is an additional case of #hendinas' answer, but where the thing you're referring to is not found because it does not have the same rendered conditions. Here is an example.
<ui:repeat id="extSyses" var="extSys" value="${cc.attrs.externalSystems}"
varStatus="extSysLoop">
<h:commandButton
id="YesButton" value="Yes" type="button"
rendered='#{(rptBean.canEditReport or rptBean.canAnnotateReport) and not extSys.closed)}'
onclick="PF('#{cc.attrs.prefix}yesDlg#{extSysLoop.index}').show()" />
<p:dialog id="extDocDlg" header='Enter document reference number'
rendered='#{rptBean.canEditReport and not extSys.closed)}'
widgetVar="#{cc.attrs.prefix}yesDlg#{extSysLoop.index}"
width="650" minWidth="650" modal="true">
... Dialog Content ...
</p:dialog>
</ui:repeat>
In this case, the widgetVar matched the value of onclick, so that was good. However, the rendered clause differed. If canEditReport was true, then everything worked fine. However, if canAnnotateReport was true, then the button would show up but it would have no dialog to display! When the button is clicked, the TypeError: PF(…) is undefined message is displayed.
In this example, the solution is to make the rendered clauses the same for both the button and the dialog it refers to.
Trying to develop a drag and drop functionality. A fieldSet in a layout has to be dragged and imitate user as if it is being dropped into another layout. Below is the xhtml code for the same :-
<h:head>
<script type="text/javascript">
function handleDrop(event, ui) {
var dropped = ui.draggable;
dropped.fadeOut('fast');
}
</script>
</h:head>
<h:body>
<h:form>
HI
<h1>Primefaces Basic Config</h1>
<p:layout style="min-width:400px;min-height:200px;">
<p:layoutUnit id="first" position="west">
<p:fieldset id="ppl" legend="Builder" toggleable="true" toggleSpeed="500" style="width:300px">
<h:panelGrid columns="2" cellpadding="5">
<h:outputText value="Bla bla bla"></h:outputText>
</h:panelGrid>
</p:fieldset>
<p:draggable for="ppl" revert="true" />
</p:layoutUnit>
<p:layoutUnit id="second" position="center">
<p:tabView id="dropdownpanel">
<p:tab title="Edit">
<h:panelGrid columns="2" cellpadding="10">
<h:outputText
value="Add question details" />
</h:panelGrid>
</p:tab>
<p:tab title="Option">
<h:panelGrid columns="2" cellpadding="10">
<h:outputText value="addtional options required" />
</h:panelGrid>
</p:tab>
<p:tab title="Logic">
<h:panelGrid columns="2" cellpadding="10">
<h:outputText value="addd logic to this tab" />
</h:panelGrid>
</p:tab>
</p:tabView>
</p:layoutUnit>
<p:droppable for="second" tolerance="touch" datasource="ppl" onDrop="handleDrop" >
<p:ajax update="first second" />
</p:droppable>
</p:layout>
</h:form>
</h:body>
</h:form>
Following is the screen shot of what i'm trying to achieve where builder fieldset can be dragged into edit area:-
But when i'm trying to drag BUILDER then following Exception is thrown :-
15:53:05,497 INFO
[javax.enterprise.resource.webcontainer.jsf.context]
(http-0.0.0.0-0.0.0.0-8081-1) java.lang.ClassCastException:
org.primefaces.component.fieldset.Fieldset cannot be cast to
javax.faces.component.UIData: java.lang.ClassCastException:
org.primefaces.component.fieldset.Fieldset cannot be cast to
javax.faces.component.UIData at
org.primefaces.component.dnd.Droppable.findDatasource(Droppable.java:231)
[primefaces-4.0.jar:4.0] at
org.primefaces.component.dnd.Droppable.queueEvent(Droppable.java:189)
[primefaces-4.0.jar:4.0] at
org.primefaces.component.behavior.ajax.AjaxBehaviorRenderer.decode(AjaxBehaviorRenderer.java:44)
[primefaces-4.0.jar:4.0] at
javax.faces.component.behavior.ClientBehaviorBase.decode(ClientBehaviorBase.java:132)
[jboss-jsf-api_2.1_spec-2.0.1.Final.jar:2.0.1.Final] at
org.primefaces.renderkit.CoreRenderer.decodeBehaviors(CoreRenderer.java:395)
[primefaces-4.0.jar:4.0] at
org.primefaces.component.dnd.DroppableRenderer.decode(DroppableRenderer.java:32)
[primefaces-4.0.jar:4.0] at
javax.faces.component.UIComponentBase.decode(UIComponentBase.java:787)
[jboss-jsf-api_2.1_spec-2.0.1.Final.jar:2.0.1.Final] at
javax.faces.component.UIComponentBase.processDecodes(UIComponentBase.java:1181)
[jboss-jsf-api_2.1_spec-2.0.1.Final.jar:2.0.1.Final]
And i've no clue to resolve.
The datasource attribute in your p:droppable element needs to refer to a UIData. Fieldset is not a UIData. If you look at the UIData Javadoc you will see that HtmlDatatable is a known subclass
I had the same problem and resolved by referencing my datatable instead of the fieldset. In your case you are using a h:panelGrid, so change
<h:panelGrid columns="2" cellpadding="5" >
to a datatable, give it an ID. Say "datasrc1".
And change your droppable's datasource to:
<p:droppable for="second" tolerance="touch" datasource="datasrc1" onDrop="handleDrop" >
Anyone know how to pass the selected row values.I need to update the data table when the when the Approve button is pressed.
mainpage.xhtml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:p="http://primefaces.org/ui"
template="/WEB-INF/layouts/standard.xhtml">
<ui:define name="notes">
<h:form>
<p:commandButton value="Sick Leave" action="sickleave" id="sickleave"/>
<p:commandButton value="Paid off Leave" action="paidleave" id="paidleave"/>
</h:form>
</ui:define>
<ui:define name="content">
<h2>Approve Leave</h2>
<h:form>
<h:dataTable value="#{employeeleave}" var="e"
styleClass="order-table"
headerClass="order-table-header"
rowClasses="order-table-odd-row,order-table-even-row"
columnClasses="order-table-odd-column,order-table-even-column"
>
<h:column>
<f:facet name="header">
No.
</f:facet>
#{e.employeeId}
</h:column>
<h:column>
<f:facet name="header">
Start Date
</f:facet>
#{e.startDate}
</h:column>
<h:column>
<f:facet name="header">
End Date
</f:facet>
#{e.endDate}
</h:column>
<h:column>
<f:facet name="header">
Reason
</f:facet>
#{e.reason}
</h:column>
<h:column>
<f:facet name="header">
Status
</f:facet>
<h:selectOneMenu id="approveleavetype" value="#{employeeLeave.status}">
<f:selectItems value="#{referenceData.approveLeave}"/>
</h:selectOneMenu>
</h:column>
<p:column>
<f:facet name="header">Action</f:facet>
<p:commandButton value="Approve Leave" action="approveleave" id="approveleave" style="margin-left:250px;">
<f:setPropertyActionListener value="#{e}" target="#{employeeleave.selected}" /></p:commandButton>
</p:column>
</h:dataTable>
</h:form>
<h2>Please Apply for Leave Here</h2>
<h:form>
<h:panelGrid columns="3" id="leaveform" >
<h:outputLabel for="beds">Select the Type of the Leave</h:outputLabel>
<h:selectOneMenu id="leavetype" value="#{employeeLeave.type}">
<f:selectItems value="#{referenceData.leaveType}"/>
</h:selectOneMenu>
<div>
<h:outputLabel for="startDate">Start Date</h:outputLabel>
<p:calendar id="startDate" label="Start Date"
value="#{employeeLeave.startDate}" pattern="MM-dd-yyyy" timeZone="EST" required="true" />
</div>
<div>
<h:outputLabel for="endDate">End Date</h:outputLabel>
<p:calendar id="endDate" label="End Date"
value="#{employeeLeave.endDate}" pattern="MM-dd-yyyy" timeZone="EST" required="true" />
</div>
<div>
<h:outputLabel for="checkoutDate">Reason</h:outputLabel>
<h:inputTextarea id="reason" value="#{employeeLeave.reason}"
required="true"
label="reason" >
</h:inputTextarea>
</div>
</h:panelGrid>
<center><p:commandButton value="Apply Leave" action="applyleave" id="applyleave" style="margin-left:250px;"/></center>
</h:form>
<br></br>
<center> <h1 style="font-size: 16px;font-weight:bold;margin-top:100px;">Leave Application</h1></center>
</ui:define>
</ui:composition>
main-flow.xml
<action-state id="ApproveLeave">
<!-- <set name="viewScope.employeeleave" value="employeeleave.selected" /> -->
<evaluate expression="leaveBo.approveLeave(employeeLeave.selectedRow)"></evaluate>
<transition to="managerpage"></transition>
</action-state>
Here am trying to get the selected row and I try to evaluate it.
But I am getting the following error.
javax.el.ELException: /WEB-INF/flows/main/managerpage.xhtml #70,86 target="#{employeeleave.selected}": Cannot convert selected of type class java.lang.String to class java.lang.Integer
at com.sun.faces.facelets.el.TagValueExpression.getType(TagValueExpression.java:103)
at com.sun.faces.facelets.tag.jsf.core.SetPropertyActionListenerHandler$SetPropertyListener.processAction(SetPropertyActionListenerHandler.java:210)
at javax.faces.event.ActionEvent.processListener(ActionEvent.java:88)
at javax.faces.component.UIComponentBase.broadcast(UIComponentBase.java:769)
at javax.faces.component.UICommand.broadcast(UICommand.java:300)
at javax.faces.component.UIData.broadcast(UIData.java:1093)
at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:794)
at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1259)
at org.springframework.faces.webflow.FlowLifecycle.invokePhase(FlowLifecycle.java:127)
at org.springframework.faces.webflow.FlowLifecycle.execute(FlowLifecycle.java:70)
at org.springframework.faces.webflow.JsfView.processUserEvent(JsfView.java:120)
at org.springframework.webflow.engine.ViewState.handleEvent(ViewState.java:226)
at org.springframework.webflow.engine.ViewState.resume(ViewState.java:196)
at org.springframework.webflow.engine.Flow.resume(Flow.java:545)
at org.springframework.webflow.engine.impl.FlowExecutionImpl.resume(FlowExecutionImpl.java:258)
at org.springframework.webflow.executor.FlowExecutorImpl.resumeExecution(FlowExecutorImpl.java:169)
at org.springframework.webflow.mvc.servlet.FlowHandlerAdapter.handle(FlowHandlerAdapter.java:183)
at org.springframework.faces.webflow.JsfFlowHandlerAdapter.handle(JsfFlowHandlerAdapter.java:48)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:923)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:852)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:882)
at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:789)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:641)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:304)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:240)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:164)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:462)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:164)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:562)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:395)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:250)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:188)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:166)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:302)
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)
As the error log says:
The method arguments for the setter setSelected need to be of type String in your case, like this:
public class Employeeleave {
public void setSelected(String newValue){
selected = newValue;
}
}