JSF 2.2 Primefaces 4.0 <p:dialog> not displaying with ManagedBeans - jsf

dialog not displaying with ManagedBeans. if datatable is not connecting Managedbean, dialog is displaying. i think dialog and datatable tags codes are correct. Maybe it depends on managedbeans pls suggest me.
<p:commandButton value="insert Qstn" onclick="PF('dlgAdd').show();"/>
<p:dataTable var="lstQstn" value="#{qstnBean.lstQstn}" rows="5" sortMode="multiple"
paginator="true"
paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
rowsPerPageTemplate="5, 10, 15">
<p:column headerText="group" sortBy="#{lstQstn.qGroup}">
<p:outputLabel value="#{lstQstn.qGroup}"/>
</p:column>
<p:column headerText="qstn">
<p:outputLabel value="#{lstQstn.qQuestion}"/>
</p:column>
<p:column headerText="type" sortBy="#{lstQstn.qType}">
<p:outputLabel value="#{lstQstn.qType}"/>
</p:column>
<p:column headerText="AskedCnt">
<p:outputLabel value="#{lstQstn.qAskedCnt}"/>
</p:column>
<p:column headerText="state">
<p:outputLabel value="#{lstQstn.qState}"/>
</p:column>
</p:dataTable>
<p:dialog id="dlg" header="fielder" widgetVar="dlgAdd" appendTo="#(body)">
<p:panelGrid>
....
</p:panelGrid>
<p:commandButton value="Хадгал" oncomplete="PF('dlgAdd').hide();"/>
</p:dialog>

You are missing an end tag for one of your columns:
<p:column headerText="qstn">
<p:outputLabel value="#{lstQstn.qQuestion}"/>

Related

Cannot associate an action on a primefaces lazy loading table

I've been trying to make use of primefaces lazy loading datatable. Without the lazy loading, the method delete(trans) gets called but not same with the lazy. Please, can someone tell me why the delete(trans) is never called when clicked. I've been on it all day (I tried with primefaces 4.x and 5.x)
<h:form>
<p:dataTable value="#{transactionView.transactions}" var="trans"
paginator="true" rows="10"
paginatorTemplate="{RowsPerPageDropdown} {FirstPageLink} {PreviousPageLink} {CurrentPageReport} {NextPageLink} {LastPageLink}"
rowsPerPageTemplate="5,10,15" lazy="true">
<p:column headerText="#{messages.trans_date}" width="100">
<h:outputText value="#{trans.transDate}">
<f:convertDateTime pattern="#{messages.date_pattern2}"/>
</h:outputText>
</p:column>
<p:column headerText="#{messages.description}">
<h:outputText value="#{trans.description}"/>
</p:column>
<p:column>
<p:commandLink value="X" style="color: red" update="#form" ajax="true"
action="#{transactionView.delete(trans)}"/>
</p:column>
</p:dataTable>
</h:form>

Primefaces datatable filtering on enter key not working

I added a global filter to the primefaces datatable. When I hit enter, the filter text is not being sent to the server for query. My code is as follows :
<h:form id="searchResultsForm">
<p:dataTable value="#{searchController.resultItems}"
var="item" editable="false"
id="searchResultsTable" lazy="true"
tableStyleClass="viewedHistoryTable"
emptyMessage="No items"
widgetVar="searchResultsTableVar"
currentPageReportTemplate="({startRecord} - {endRecord} of {totalRecords})"
paginatorTemplate="{FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown} {CurrentPageReport}"
paginator="true" rows="25" rowsPerPageTemplate="10,25,50,100"
rowKey="#{item.abbr}">
<f:facet name="header">
<p:outputPanel>
<h:outputText value="Search:" />
<p:inputText id="globalFilter" onkeyup="if (event.keyCode === 13){PF('searchResultsTableVar').filter();}" style="width:150px" placeholder="Filter results"/>
</p:outputPanel>
</f:facet>
<p:column rendered="true">
<h:outputText value="#{item.title}" />
<br />
<h:outputText value="#{item.abbr}" styleClass="searchResultsAbbr" />
</p:column>
</p:dataTable>
</h:form>
If I remove the if condition to check the event keycode of Enter, the filter string is sent to the server on every key press. Not sure why the client is sending a empty string on enter. Any ideas?
I wanted to share my working code :
<h:form id="searchResultsForm">
<p:dataTable value="#{searchController.resultItems}"
var="item" editable="false"
id="searchResultsTable" lazy="true"
tableStyleClass="viewedHistoryTable"
emptyMessage="No items"
widgetVar="searchResultsTableVar"
currentPageReportTemplate="({startRecord} - {endRecord} of {totalRecords})"
paginatorTemplate="{FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown} {CurrentPageReport}"
paginator="true" rows="25" rowsPerPageTemplate="10,25,50,100"
rowKey="#{item.abbr}" selectionMode="single" selection="#{searchController.currItem}">
<f:facet name="header">
<h:panelGroup>
<p:outputPanel style="padding-bottom: 4px;">
<p:inputText id="globalFilter" onchange="PF('searchResultsTableVar').filter();" style="width:60%;" placeholder="Filter results"/>
<p:commandButton id="Search" value="Search" process="#this" update="#this" style="font-size: 0.8em;"/>
</p:outputPanel>
</h:panelGroup>
</f:facet>
<p:column rendered="true">
......
</p:column>
</p:dataTable>
</h:form>
You could just use a jquery attachment so remove the 'onkeyup' altogether.
$(document).ready(function() {
$('#globalFilter').keypress(function(event) {
if ((event.keyCode || event.which) == 13) {
PF('searchResultsTableVar').filter();
}
});
});
Tested here: http://jsfiddle.net/Zcfga/3/

PrimeFaces 3.5.14 DataTable using FilterBy

I'm using PrimeFaces 3.5, with a datatable that i need use a FilterBy component.
In show case, it works ok: http://www.primefaces.org/showcase/ui/datatableFiltering.jsf
well, when i do my first filter, its work and it show me result, but when i do a second filter, it stop working.
See my xHTML:
<p:dataTable id="users"
var="user"
value="#{userMB.users}"
rowKey="#{user.id}"
selection="#{userMB.userSelected}"
selectionMode="single"
rows="10"
paginator="true"
filteredValue="#{userMB.filteredUser}"
paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
>
<p:column headerText="Id" >
#{user.id}
</p:column>
<p:column headerText="Login" filterBy="#{user.login}">
#{user.login}
</p:column>
</p:dataTable>
Observations: userMB its my managed bean, #SessionScoped
users it's a List
filteredUser it's a List
it's all... thank a attention :)
I am new here too, but this example worked for me.
I see some problems in your example.
First if you put var="user" then rowKey="#{userMB.id}" must be rowKey="#{user.id}"
Same here:
As you see I removed filterValue="#{usuario.login}" as I don't used this.
In the end this should look like this:
<p:dataTable id="users"
var="user"
value="#{userMB.users}"
rowKey="#{user.id}"
selection="#{userMB.userSelected}"
selectionMode="single"
rows="10"
paginator="true"
filteredValue="#{userMB.filteredUser}"
paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
>
<p:column headerText="Id" >
#{user.id}
</p:column>
<p:column headerText="Login" sortBy="#{user.login}" filterBy="#{user.login}">
#{user.login}
</p:column>
</p:dataTable>
Maybe its not problem, but I used #ViewScoped.
Hint: you can be interested in filterMatchMode="contains"
I hope I helped you.
this is a working PF3.5 datatable dont forget to wrap it inside an
<p:dataTable id="surveyTable" var="survey" value="#{surveyBean.surveys}" widgetVar="surveysTable"
emptyMessage="Keine Umfragen zu diesem Suchbegriff vorhanden" filteredValue="#{surveyBean.filteredSurveys}"
paginator="true" rows="10"
paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
rowsPerPageTemplate="5,10,15">
<f:facet name="header">
Liste der Umfragen
<p:outputPanel>
<h:outputText value="Suchen:" />
<p:inputText id="globalFilter" onkeyup="surveysTable.filter()" style="margin-left:5px;width:150px" />
</p:outputPanel>
</f:facet>
<p:column id="idColumn" headerText="ID" filterBy="{survey.id}" filterMatchMode="contains">
<h:outputText value="#{survey.id}" />
</p:column>
<p:column id="titleColumn" filterBy="#{survey.title}" headerText="Bezeichnung" filterMatchMode="contains">
<h:outputText value="#{survey.title}" />
</p:column>
<p:column id="activeColumn" headerText="Aktiv" filterBy="#{survey.active}" filterOptions="#{surveyBean.surveyOptions}"
filterMatchMode="exact">
<h:outputText value="#{survey.active}" />
</p:column>
<p:column id="toggleColumn">
<p:rowToggler />
</p:column>
<p:rowExpansion>
<h:panelGrid id="display" columns="2" cellpadding="4" style="width:300px;"
styleClass=" ui-widget-content grid">
<f:facet name="header">
Details der Umfrage
</f:facet>
<h:outputText value="Bezeichnung:" />
<h:outputText id="model" value="#{survey.title}" />
<h:outputText value="Status:" />
<h:outputText id="year" value="#{survey.active}" />
<h:outputText value="ID:" />
<h:outputText value="#{survey.id}"/>
</h:panelGrid>
</p:rowExpansion>
</p:dataTable>

p:datatable multiple select with checkboxes. Rowtoggler triggers event

I have a datatable inside another datatable. The nested table I need to have a multiple selection checkboxes, a button to fire actionlistener and a p:rowToggler to show more data in row. The toggler and commandbutton works fine without the selection column in the table, but when I add this column the commandButton doesn't go to the backing bean, toggler on click doesn't work properly, and setSelected isn't called. Both throw a NP. I'm using 3.4.2 is this feature on newer releases only?
SEVERE: FullAjaxExceptionHandler: An exception occurred during processing JSF ajax request. Error page '/error.xhtml' will be shown.
java.lang.NullPointerException
Table
<p:dataTable id="gro" var="g" value="#{requestBean.main.childRequest}" styleClass="veaGrid"
paginator="true" rows="1" paginatorTemplate="{CurrentPageReport}" >
<p:column>
<p:ajaxStatus >
<f:facet name="start">
<p:graphicImage value="/resources/images/ajaxloadingbar.gif" />
</f:facet>
<f:facet name="complete">
<h:outputText value="" />
</f:facet>
</p:ajaxStatus>
<p:dataTable id="group" var="g2" value="#{g.groups}" rowKey="#{g2.group_name}" selection="#{requestBean.selectedGroups}" >
<p:column selectionMode="multiple" style="width:2%" />
<p:column headerText="#{g.systemCd} - Groups" style="width:25%" >
#{g2.group_name}
</p:column>
<p:column style="width:2%">
View Users <p:rowToggler />
</p:column>
<p:rowExpansion>
<p:dataTable styleClass="veaGrid" var="g3" value="#{g2.group_members}" sortOrder="descending"
paginator="true" rows="10"
paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
filteredValue="#{requestBean.filteredMembers}">
<p:column filterBy="#{g3.first_name}">
<h:outputText value="#{g3.first_name}"/>
</p:column>
<p:column filterBy="#{g3.last_name}">
<h:outputText value="#{g3.last_name}"/>
</p:column>
<p:column filterBy="#{g3.signon}">
<h:outputText value="#{g3.signon}"/>
</p:column>
</p:dataTable>
</p:rowExpansion>
</p:dataTable>
<center>
<p:commandButton id="continue" value="Continue" actionListener="#{requestBean.saveGroups}"/>
</center>
</p:column>
</p:dataTable>
Found the problem.. I had the requestBean.selectedGroups set to
ArrayList<Group>
I changed the property to
Group[]
and now everything is functional again.

Primefaces dataTable Sorting does not seem to work

I am having difficulties sorting a dynamic dataTable
dataTable
<h:form prependId="false" id="Main_Form">
<p:dataTable id="dataTable" var="c" value="#{databaseSearch.customerList}"
paginator="true" rows="10" paginatorAlwaysVisible="false"
paginatorTemplate="Page {CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} Rows per page {RowsPerPageDropdown}"
rowsPerPageTemplate="5,10,15,30" draggableColumns="True">
<p:column sortBy="#{c.machine}" headerText="Machine">
<h:outputText value="#{c.machine}" />
</p:column>
<p:column sortBy="#{c.company}" headerText="Company">
<h:outputText value="#{c.company}" />
</p:column>
<p:column sortBy="#{c.contact}" headerText="Contact">
<h:outputText value="#{c.contact}" />
</p:column>
<p:column sortBy="#{c.phone}" headerText="Phone">
<h:outputText value="#{c.phone}" />
</p:column>
<p:column sortBy="#{c.email}" headerText="Email">
<h:outputText value="#{c.email}" />
</p:column>
<p:column exportable="false" headerText="Modify">
<center>
<p:commandButton id="basic" value="Update"
action="#{updateEntry.setMachine(c.machine)}"
oncomplete="dlg1.show();"
styleClass="ui-Machinebutton" update=":Update_Entry"/>
<p:tooltip for="basic" value="Update/Delete Database Entry"
showEffect="fade" hideEffect="fade" />
</center>
</p:column>
</p:dataTable>
</h:form>
I am using a #SessionScoped bean where databaseSearch.customerList would query the database and populate the dataTable. When I click on the column name to sort, the sort arrow mark changes but the table contents do not sort.
I am using PF 3.4.2
If you are querying your database in your getCustomerList method in every request this will not work. You may try with a local variable
public class DatabaseSearch{
private List<C> customerList;
public List<C> getCustomerList () {
if (customerList == null)
customerList = dao.getcustomerList();
return customerList ;
}
}

Resources