primefaces ui is not rendering properly - user-interface

I'm having a problem with primefaces ui. It doesnt render icon that it was supposed to be rendered when I use and the problem is not happening only on this but also on many other pages. I haven't used jquery.
I dont know what's wrong. Googled it but didnt find an answer.
Here is my code
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:ui="http://java.sun.com/jsf/facelets"
template="/WEB-INF/faces/template.xhtml"
xmlns:f="http://xmlns.jcp.org/jsf/core"
xmlns:jsf="http://xmlns.jcp.org/jsf" xmlns:p="http://primefaces.org/ui"
xmlns:prettyfaces="http://ocpsoft.com/prettyfaces">
<ui:param name="title" value="List of Employee"/>
<ui:define name="breadcrum1">
<li><h:link value="Employee Management" outcome="pretty:home"/></li>
<li><h:link value="List Employee Record" outcome="pretty:list_employee"/></li>
</ui:define>
<ui:define name="content">
<div class="container">
<div class="row">
<div class="col-xs-10 col-md-10 span3">
<p:messages id="messages" autoUpdate="true" closable="true" globalOnly="true" style="text-align: center;"/>
<h:form id="form">
<p:dataTable
class="panel-primary table table-condensed"
var="employee" value="#{dtLazyView.lazyModel}" paginator="true" rows="10"
emptyMessage="No Employee found with given criteria"
paginatorTemplate="{RowsPerPageDropdown} {FirstPageLink} {PreviousPageLink} {CurrentPageReport} {NextPageLink} {LastPageLink}"
rowsPerPageTemplate="5,10,15" selectionMode="single" selection="#{dtLazyView.selectedEmployee}" widgetVar="employeeTable" lazy="true">
<f:facet name="header">
Employee Information
<h:outputText value="Search all fields:" />
<p:inputText id="globalFilter" onkeyup="PF('employeeTable').filter()" style="width:150px" placeholder="Enter keyword"/>
</f:facet>
<p:column headerText="Id">
<h:outputText value="#{employee.employeeCode}" />
</p:column>
<p:column headerText="Employee Name">
<h:outputText value="#{employee.employeeName}" />
</p:column>
<p:column headerText="Employee Mobile Number">
<h:outputText value="#{employee.contact.mobileNumber}" />
</p:column>
<p:column headerText="Employee Role" >
<h:outputText value="#{employee.detail.employeeRole}" />
</p:column>
<p:column headerText="Option">
<h:commandButton action="#{employeeEditController.loadData(employee)}" value="Edit" class="btn btn-primary" style="margin-left: 40px;"> <f:ajax execute="#form"/></h:commandButton>
<p:commandButton update=":form:employeeDetail" oncomplete="PF('employeeDialog').show()" icon="ui-icon-search" title="View">
<f:setPropertyActionListener value="#{employee}" target="#{dtLazyView.selectedEmployee}" />
</p:commandButton>
</p:column>
</p:dataTable>
<p:dialog header="Employee Info" widgetVar="employeeDialog" modal="true" showEffect="fade" hideEffect="fade" resizable="false" styleClass="">
<p:outputPanel id="employeeDetail" style="text-align:center;">
<p:panelGrid columns="2" rendered="#{not empty dtLazyView.selectedEmployee}" columnClasses="label,value">
<f:facet name="header">
<img src="../../imageshandler/#{dtLazyView.selectedEmployee.employeePicture}" class="img-responsive" style="width:200px;height: 200px;margin-left: 100px;border-radius: 50%"/>
</f:facet>
<h:outputText value="Name :" style="color: black"/>
<h:outputText value="#{dtLazyView.selectedEmployee.employeeName}" />
<h:outputText value="DOB :" style="color: black"/>
<h:outputText value="#{dtLazyView.selectedEmployee.employeeDob}" />
<h:outputText value="Gender :" style="color: black"/>
<h:outputText value="#{dtLazyView.selectedEmployee.sex}" style="color:#{dtSelectionView.selectedCar.color}"/>
<h:outputText value="Salary : " style="color: black" />
<h:outputText value="Rs : #{dtLazyView.selectedEmployee.salary.basicSalary}" />
<h:outputText value="Working date :" style="color: black"/>
<h:outputText value="#{dtLazyView.selectedEmployee.employeeDateOfCommencement}"/>
<h:outputText value="Employee Job Specification :" style="color: black"/>
<h:inputTextarea value="#{dtLazyView.selectedEmployee.detail.jobSpecification}" readonly="true"/>
</p:panelGrid>
</p:outputPanel>
</p:dialog>
</h:form>
</div>
</div>
</div>
</ui:define>

According to Primefaces, you can use Font Awesome for the icons, so try replacing
icon="ui-icon-search"
with
icon="fa fa-search"
Keep in mind
Font Awesome icons are provided out of the box within PrimeFaces. In
order to enable Font Awesome support, enable primefaces.FONT_AWESOME
setting as true via a context param.

Related

Primefaces TreeTable sorting freze collapse

is it possible to keep the behaviour more stable?
what I have:
an Tree table with 3 columns, first has collapsed stuff in it
if I open one and close it, then click on sort
it is open after that
what I would like to have:
keep it closed if it was closed before sort
<h:form id="form">
<p:treeTable value="#{ttBasicView.root}" var="document">
<f:facet name="header">
FritzBox Smart Home Daten
</f:facet>
<p:column headerText="Name" >
<h:outputText value="#{document.name}" />
</p:column>
<p:column headerText="Gesamtverbrauch (in kWh)" sortBy="#{document.gesamtverbrauch}" actionListener="#{BasicView.expandAll}">
<h:outputText value="#{document.gesamtverbrauch}" />
</p:column>
<p:column headerText="aktuelle Temperatur" sortBy="#{document.akttemperatur}">
<h:outputText value="#{document.akttemperatur}" />
</p:column>
<p:column style="width:24px">
<p:commandLink update=":form:documentPanel" oncomplete="PF('documentDialog').show()" title="View Detail" styleClass="ui-icon ui-icon-search">
<f:setPropertyActionListener value="#{document}" target="#{ttBasicView.selectedDocument}" />
</p:commandLink>
</p:column>
</p:treeTable>
<p:dialog id="dialog" header="Document Detail" showEffect="fade" widgetVar="documentDialog" modal="true" resizable="false">
<p:outputPanel id="documentPanel">
<p:panelGrid columns="2" columnClasses="label,value" rendered="#{not empty ttBasicView.selectedDocument}">
<h:outputLabel for="name" value="Name: " />
<h:outputText id="name" value="#{ttBasicView.selectedDocument.name}" style="font-weight:bold" />
<h:outputLabel for="gesamtverbrauch" value="Gesamtverbrauch: " />
<h:outputText id="gesamtverbrauch" value="#{ttBasicView.selectedDocument.gesamtverbrauch}" style="font-weight:bold" />
<h:outputLabel for="akttemperatur" value="aktuelle Temperatur: " />
<h:outputText id="akttemperatur" value="#{ttBasicView.selectedDocument.akttemperatur}" style="font-weight:bold" />
</p:panelGrid>
</p:outputPanel>
</p:dialog>
</h:form>
That was my problem too.
Try it in your treeTable :
<p:ajax event="collapse"
onstart="handleLoadingStarted()"
oncomplete="handleLoadingStopped()" />

error null pointer JSF transfer data

I made this code here, q aims to list the values ​​of the bank, and that the User can update a date, even through the dataTable. So far, I managed to get to this point, only that, sets the value that the User enters. I can not find this value anywhere in the world, already ran tdo and the value that is typed in the box, does not come. I used several types of variables, but nothing.
<p:dataTable id="dataTable"
var="Arquivo"
paginator="true"
paginatorPosition="bottom"
rowsPerPageTemplate="100"
rows="100"
sortBy="#{Arquivo.id}"
value="#{arquivoBean.dataModelArquivo}"
rowStyleClass="#{Arquivo.pendente eq 1 ? 'ok' : 'erro'}"
>
<p:column headerText="ID">
#{Arquivo.id}
</p:column>
<p:column headerText="Nome">
#{Arquivo.nome}
</p:column>
<p:column headerText="Envio">
#{Arquivo.dataEnvio}
</p:column>
<p:column headerText="Produto" width="10px;">
<h:form id="formProduto">
<p:commandButton icon="ui-icon-circle-zoomout" value=""
action="#{arquivoBean.listarProdutoPorArquivo()}"
oncomplete="prodDialog.show()"
update=":form:dataTableProd"
onclick="listarProd([{name: 'ArquivoId', value:#{Arquivo.id}}]);">
<f:setPropertyActionListener value="#{Arquivo}" target="#{arquivoBean.arquivo}"/>
</p:commandButton>
</h:form>
</p:column>
<p:column headerText="Data" >
<p:inputMask id ="entrada#{cc.clientId}" mask="99/99/9999" value="#{Arquivo.dataEntrada}"
onkeypress="if (event.keyCode === 13) {
test([{name: 'ArquivoId', value:#{Arquivo.id}}]);
return;
};"
size="8">
<f:convertDateTime pattern="dd/MM/yyyy"/>
</p:inputMask>
</p:column>
</p:dataTable>
After much poking around, I found this error inspector elements of chrome, tab networks:
<partial-response id="j_id1"><error><error-name>class java.lang.NullPointerException</error-name><error-message><![CDATA[]]></error-message></error></partial-response>
I fixed remove the form block and put many forms in place a need.
just it make works.
<?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://xmlns.jcp.org/jsf/html"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:p="http://primefaces.org/ui"
xmlns:f="http://java.sun.com/jsf/core">
<ui:decorate template="/resources/Template.xhtml">
<ui:define id="content" name="content">
<p:growl id="war"/>
<style type="text/css">
.ok{
color: #336600
}
.erro{
color: #D20005;
}
</style>
<div style="width: 90%; margin-left: auto; margin-right: auto; ">
<h:form id="form">
<br/>
<br/>
<p:panel>
<f:facet name="header">
Lista de Arquivos Armazenados
</f:facet>
<h:form id="pesquisar">
<p:toolbar style="width: 100%;">
<p:toolbarGroup align="left" >
<h:panelGrid columns="1" cellpadding="0">
</h:panelGrid>
</p:toolbarGroup>
<p:toolbarGroup align="right">
<h:panelGrid columns="5" cellpadding="0">
<h:outputLabel value="De: "/>
<p:inputMask mask="99/99/9999" value="#{arquivoBean.dataInicial}" size="10"/>
<h:outputLabel value="Até: "/>
<p:inputMask mask="99/99/9999" value="#{arquivoBean.datafinal}" size="10"/>
<p:commandButton value="Buscar" action="#{arquivoBean.listar()}" update=":form:dataTable" ajax="false"/>
<br/>
<p:selectBooleanCheckbox id="check" value="#{arquivoBean.pendente}"
itemLabel="Pendente">
<p:ajax process="#this" event="change" listener="#{arquivoBean.listarPendente()}" update=":form:dataTable" />
</p:selectBooleanCheckbox>
<p:button value="Ajustar Datas" outcome="/telas/armazenado/listaData.xhtml"/>
</h:panelGrid>
</p:toolbarGroup>
</p:toolbar>
</h:form>
</p:panel>
<br/>
<p:dataTable id="dataTable"
var="Arquivo"
paginator="true"
paginatorPosition="bottom"
rowsPerPageTemplate="100"
rows="100"
sortBy="#{Arquivo.id}"
value="#{arquivoBean.dataModelArquivo}"
rowStyleClass="#{Arquivo.pendente eq 1 ? 'ok' : 'erro'}"
emptyMessage="Você ainda não ativou uma empresa ou não existe postagem para esta Empresa">
<p:column headerText="ID">
#{Arquivo.id}
</p:column>
<p:column headerText="Nome">
#{Arquivo.nomeMury}
</p:column>
<p:column headerText="Envio">
#{Arquivo.dataEnvio}
</p:column>
<p:column headerText="Produto" width="10px;">
<h:form id="formProduto">
<p:commandButton icon="ui-icon-circle-zoomout" value=""
action="#{arquivoBean.listarProdutoPorArquivo()}"
oncomplete="prodDialog.show()"
update=":form:dataTableProd"
onclick="listarProd([{name: 'ArquivoId', value:#{Arquivo.id}}]);">
<f:setPropertyActionListener value="#{Arquivo}" target="#{arquivoBean.arquivo}"/>
</p:commandButton>
</h:form>
</p:column>
</p:dataTable>
<p:dialog closeOnEscape="true"
widgetVar="prodDialog"
modal="true"
header="Lista de Produtos da NF-e"
style="width: 300; height: 500"
position="center">
<p:dataTable
id="dataTableProd"
var="XmlItens"
paginator="true"
paginatorPosition="bottom"
rowsPerPageTemplate="10"
rows="10"
value="#{arquivoBean.listaProd}">
<p:column headerText="ID">
#{XmlItens.id}
</p:column>
<p:column headerText="Nome">
#{XmlItens.descricaoProd}
</p:column>
<p:column headerText="Envio">
#{XmlItens.chaveNfe}
</p:column>
</p:dataTable>
<p:remoteCommand name="test" action="#{arquivoBean.inserirDataNota()}">
<f:setPropertyActionListener value="#{Arquivo}" target="#{arquivoBean.arquivo}"/>
</p:remoteCommand>
<p:remoteCommand name="listarProd" action="#{arquivoBean.listarProdutoPorArquivo()}" update=":form:dataTableProd">
<f:setPropertyActionListener value="#{Arquivo}" target="#{arquivoBean.arquivo}"/>
</p:remoteCommand>
</p:dialog>
</h:form>
</div>
</ui:define>
</ui:decorate>
</html>

cannot update component from inside overlaypanel inside datatable primefaces

I want to update one component from another inside p:overlayPanel inside p:datatable
here is the code :
<p:tabView id="monpanel">
<p:tab id="tab1" title=".....">
.....
</p:tab>
<p:tab id="tab2" title=".....">
.....
</p:tab>
<p:tab id="tab3" title="Stock et fournisseurs">
<h:panelGrid>
<h:outputLabel value="Stock : "
style="text-decoration: underline;font-weight: 900;" />
<p:commandButton id="carBtn" value="Ajouter" type="button" />
<p:outputLabel id="nombref"
value="#{articlesMB.NBF} fournisseurs séléctionnés." />
<p:overlayPanel appendToBody="true" widgetVar="overlayp"
id="carPanel" for="carBtn" hideEffect="fade" dynamic="true">
<p:dataTable id="table" var="car" rowKey="#{car.fournisseurId}"
value="#{articlesMB.listfournisseurs}"
selection="#{articlesMB.selectedFournisseurs}" rows="10"
paginator="true">
<p:column selectionMode="multiple" style="width:20px" />
<p:column headerText="Id">
<h:outputText value="#{car.fournisseurId}" />
</p:column>
<p:column headerText="Nom">
<h:outputText value="#{car.personne.nom}" />
</p:column>
<f:facet name="footer">
<p:commandButton id="multiViewButton" value="View"
icon="ui-icon-search" update=":nombref"
oncomplete="multiCarDialog.show()" />
</f:facet>
</p:dataTable>
</p:overlayPanel>
</p:tab>
<p:tabview>
I tested update=":nombref" and update="monpanel:nombref" and update=":monpanel:nombref" but always I have this error :
com.sun.faces.context.PartialViewContextImpl$PhaseAwareVisitCallback visit
GRAVE: javax.faces.FacesException: Cannot find component with identifier ":nombref" referenced from "monpanel:table:multiViewButton".
How can I fix this error?

ajax is not updating a component situated in another <ui:define

Hi i have a command link so when click it i action="#{projectAdminisrationMB.showGroups(userObj)}" a fieldset will be rendred <p:fieldset legend="Manage User Groups" id="manageUserGroupsFS" rendered="#{projectAdminisrationMB.manageUserGroupsFSFlag}">
when the fieldset was in the same <ui:define name="body"> everything works but when i put it in a separated ui:define it will not be rendered.
Here's the code :
<ui:define name="body">
<h:form id="manageProjeUFform">
<div class="right">
<p:growl id="growl" showDetail="true" sticky="true" />
<br/><br/><br/><br/>
<h:panelGrid columns="2" cellpadding="10">
<p:column>
<p:fieldset legend=" Users ">
<h:panelGrid columns="2" cellpadding="10">
<p:dataTable border="1" value="#{projectAdminisrationMB.projectUsersList}"
id="projectUserDt"
var="userObj"
rowKey="#{userObj.name}"
selection="#{projectAdminisrationMB.selectedExistingProjectUser}"
selectionMode="single"
rowIndexVar="rowIndex"
binding="#{table1}">
<p:column id="column1">
<f:facet name="header">
<h:outputText value="Login"></h:outputText>
</f:facet>
<h:outputText value="#{userObj.name}"/>
</p:column>
<p:column id="column2">
<f:facet name="header">
<h:outputText value="Entire Name"></h:outputText>
</f:facet>
<h:outputText value="#{userObj.lastName}"></h:outputText>
<h:outputText value="#{userObj.firstName}"></h:outputText>
</p:column>
<p:column id="column5">
<f:facet name="header">
<h:outputText value="Groups"></h:outputText>
</f:facet>
<p:commandLink id="manageUG" title="Manage User Groups" style="margin-right:5px" update=":rightContentform:manageUserGroupsFS" action="#{projectAdminisrationMB.showGroups(userObj)}" ajax="true">
<h:graphicImage value="../images/cssImg/manage-groups-icon.png" />
<f:setPropertyActionListener target="#{projectAdminisrationMB.selectedUserRow}" value="#{userObj}" />
<f:setPropertyActionListener target="#{projectAdminisrationMB.selectedUserRow.dbRowIndex}" value="#{table.rowIndex}" />
</p:commandLink>
</p:column>
<f:facet name="footer">
<p:commandButton id="addProjectUserdlg" value=" Add " onclick="dlg1.show()" />
<p:commandButton id="deleteProjectUserdlg" value=" Delete " onclick="confirmation.show()"/>
</f:facet>
</p:dataTable>
</h:panelGrid>
</p:fieldset>
</div>
</h:form>
</ui:define>
<h:panelGrid columns="3">
<h:panelGrid id="display" header="User Detail" columns="2" cellpadding="4">
<f:facet name="header">
<p:graphicImage value="/images/users/user.png"/>
</f:facet>
<h:outputText value="Login:" />
<h:outputText value="#{projectAdminisrationMB.selectedUserRow.lastName}" />
<h:outputText value="Name:" />
<h:outputText value="#{projectAdminisrationMB.selectedUserRow.lastName}" />
<h:outputText value="First Name:" />
<h:outputText value="#{projectAdminisrationMB.selectedUserRow.firstName}" />
<h:outputText value="Email:" />
<h:outputText value="#{projectAdminisrationMB.selectedUserRow.email}" />
<h:outputText value="Phone:" />
<h:outputText value="#{projectAdminisrationMB.selectedUserRow.phoneNumber}" />
</h:panelGrid>
<p:pickList id="pickList" value="#{projectAdminisrationMB.selectedUserGroups}" var="group"
itemLabel="#{group}" itemValue="#{group}" converter="groupConverter" >
<f:facet name="sourceCaption">Belong To</f:facet>
<f:facet name="targetCaption">Exclude From</f:facet>
<p:column style="width:25%">
<p:graphicImage value="/images/group/#{group.name}.gif" />
</p:column>
<p:column style="width:75%;">
#{group.name}
</p:column>
<p:ajax event="transfer" listener="#{projectAdminisrationMB.onTransferGroup}" update=":manageProjeUFform:growl" />
</p:pickList>
<p:commandButton id="saveGroupsBtn" value="Save" update=":manageProjeUFform:growl" actionListener="#{projectAdminisrationMB.saveUserGroupsModif}"/>
</h:panelGrid>
</p:fieldset>
</h:form>
</ui:define>
Any help will be appreciated .
here's the solution enjoy it :)
<p:commandLink id="manageUG" title="Manage User Groups" style="margin-right:5px"
update="#all" action="#{projectAdminisrationMB.showGroups(userObj)}" ajax="true">
<h:graphicImage value="../images/cssImg/manage-groups-icon.png" />
<f:setPropertyActionListener target="#{projectAdminisrationMB.selectedUserRow}" value="#{userObj}" />
<f:setPropertyActionListener target="#{projectAdminisrationMB.selectedUserRow.dbRowIndex}" value="#{table.rowIndex}" />
</p:commandLink>
i used #all to update the ui define section that's it

JSF : dynamically loaded page commandButton not working

I have a page that contains a PrimeFaces accordion panel, in each panel is a PrimeFaces datatable. Below the datatable is a button "Add study" for example and when this button is click I want to dynamically load a page into a <h:panelGroup> using a <ui:include>. When the button is being click I want to dynamically change the src value from the <ui:include> so that my page is loaded in the <h:panelGroup>. Now the problem is the following:
My managed bean is set to #RequestScoped and when I click on my button nothing is being rendered.
If I set my managed bean to #SessionScoped the <h:panelGroup> is filled after the second click on the button, the first click doesn't do anything.
Used technologies : JSF2.0, PrimeFaces, Facelets
Here are some code snippets :
Main Page
<h:panelGroup id="content" layout="block">
<ui:include src="#{studyBean.includePage}"/>
</h:panelGroup>
<div id="dashboard">
<h:form id="form" prependId="false">
<h:outputText value="Welkom #{loginBean.username}"/>
<p:accordionPanel autoHeight="true" effect="bounceslide">
<p:tab title="My studies">
<p:dataTable var="study" value="#{studyBean.studiesByUser}" id="studyTable"
emptyMessage="No studies found for given user" paginator="true" rows="10"
paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
rowsPerPageTemplate="5,10,15" rowSelectListener="#{studyBean.onRowSelect}"
selectionMode="single">
<p:column headerText="StartDate" sortBy="#{study.startDate}"
filterBy="#{study.startDate}"
filterMatchMode="contains" style="width: 100px;">
<h:outputText value="#{study.startDate}">
<f:convertDateTime pattern="dd/MM/yyyy" type="date" timeZone="CET"/>
</h:outputText>
</p:column>
<p:column headerText="EndDate" sortBy="#{study.endDate}"
filterBy="#{study.endDate}}"
filterMatchMode="contains" style="width: 100px;">
<h:outputText value="#{study.endDate}">
<f:convertDateTime pattern="dd/MM/yyyy" type="date" timeZone="CET"/>
</h:outputText>
</p:column>
<p:column headerText="School" sortBy="#{study.school}" filterBy="#{study.school}}"
filterMatchMode="contains" style="width: 100px;">
<h:outputText value="#{study.school}"/>
</p:column>
<p:column headerText="Specialization" sortBy="#{study.specialization}"
filterBy="#{study.specialization}}" filterMatchMode="contains"
style="width: 100px;">
<h:outputText value="#{study.specialization}"/>
</p:column>
<p:column headerText="Remarks" sortBy="#{study.remarks}"
filterBy="#{study.remarks}}"
filterMatchMode="contains" style="width: 100px;">
<h:outputText value="#{study.remarks}"/>
</p:column>
</p:dataTable>
<h:commandButton id="btnAddStudy" title="Add Study" value="Add Study">
<f:ajax render=":content" execute="form" listener="# {studyBean.navigate}"/>
<f:param name="action" value="add"/>
</h:commandButton>
</p:tab>
</p:accordionPanel>
</h:form>
So as you can see is my <h:panelGroup> outside my form.
This is the included page (as example)
<h:body>
<ui:composition template="../template/template.xhtml">
<ui:define name="body">
<f:view contentType="text/html">
<ui:composition>
<h:form id="studyForm" prependId="false">
<p:messages />
<h:message for="startDate"/>
<h:message for="endDate"/>
<h:message for="school"/>
<h:message for="diploma1"/>
<h:message for="diploma2"/>
<h:message for="diploma3"/>
<h:message for="specialization1"/>
<h:message for="specialization2"/>
<h:message for="specialization3"/>
<h:message for="remarks1"/>
<h:message for="remarks2"/>
<h:message for="remarks3"/>
<h:outputText class="label" value="Start date: "/>
<h:inputText id="startDate" styleClass="inputtext validate[required,custom[date]]"
value="#{studyBean.startDate}">
<f:convertDateTime pattern="dd/MM/yyyy" timeZone="CET"/>
</h:inputText>
<h:outputText class="label" value="End date: "/>
<h:inputText id="endDate" styleClass="inputtext validate[required,custom[date]]"
value="#{studyBean.endDate}">
<f:convertDateTime pattern="dd/MM/yyyy" timeZone="CET"/>
</h:inputText>
<h:outputText class="label" value="school: "/>
<h:inputText id="school" styleClass="inputtext validate[required, maxSize[5]]"
value="#{studyBean.school}"/>
<h:outputText class="label" value="Specialization: "/>
<h:inputText id="specialization1" styleClass="inputtext validate[maxSize[50]]"
value="#{studyBean.specialization[0]}"/>
<h:inputText id="specialization2" styleClass="inputtext validate[maxSize[50]]"
value="#{studyBean.specialization[1]}"/>
<h:inputText id="specialization3" styleClass="inputtext validate[maxSize[50]]"
value="#{studyBean.specialization[2]}"/>
<h:outputText class="label" value="Diploma: "/>
<h:inputText id="diploma1" styleClass="inputtext validate[maxSize[50]]"
value="#{studyBean.diploma[0]}"/>
<h:inputText id="diploma2" styleClass="inputtext validate[maxSize[50]]"
value="#{studyBean.diploma[1]}"/>
<h:inputText id="diploma3" styleClass="inputtext validate[maxSize[50]]"
value="#{studyBean.diploma[2]}"/>
<h:outputText class="label" value="remarks: "/>
<h:inputText id="remarks1" styleClass="inputtext validate[maxSize[200]]"
value="#{studyBean.remarks[0]}"/>
<h:inputText id="remarks2" styleClass="inputtext validate[maxSize[200]]"
value="#{studyBean.remarks[1]}"/>
<h:inputText id="remarks3" styleClass="inputtext validate[maxSize[200]]"
value="#{studyBean.remarks[2]}"/>
<h:commandButton action="cancel" value="cancel" immediate="true"/>
<p:commandButton id="btnAddStudyDetail" value="add study" actionListener="#{studyBean.addStudy}"
update="studyTable" oncomplete="clearAddStudy()"/>
</h:form>
</ui:composition>
</f:view>
</ui:define>
</ui:composition>
</h:body>
Managed Bean #RequestScoped
#ManagedBean
#RequestScoped
public class StudyBean {
public String navigate() {
FacesContext facesContext = FacesContext.getCurrentInstance();
try {
action = (((HttpServletRequest) facesContext.getExternalContext().getRequest()).getParameter("action"));
if (action.equals("add")) {
//vull de velden
includePage = "studyDetail.xhtml";
}
facesContext = FacesContext.getCurrentInstance();
UIViewRoot root = facesContext.getViewRoot();
UIComponent form = root.findComponent("form");
dataTable = form.findComponent("studyTable");
System.out.println(dataTable);
System.out.println(root);
} catch (Exception e) {
facesContext.addMessage("form", new FacesMessage("You must select a study."));
}
return null;
}
}
Thanks in advance.
UPDATE
Now I am able to dynamically load the page in my <ui:include> but I have another problem now, when the page is loaded and I want to click on my button in the loaded page the action to which it is bound doesn't execute. So I don't get into my backing bean, I already tried to put the scope of my bean to #ViewScoped but no success.
Please help me as I am getting desperate.

Resources