If i select a row in my Datatable i always following : Feb 24, 2014 1:01:42 AM com.sun.faces.context.PartialViewContextImpl processPartial
Information: java.lang.IllegalArgumentException: argument type mismatch . The Problem is ajax tag. If i remove it i get no exception
i use primefaces 4.0 and jsf 2.1
<p:dataTable id="inboxTable" var="task_toUser" value="#{taskboxBean.taskboxInboxList}" paginator="true"
widgetVar="inboxTable" rows="5" selection="#{taskboxBean.selectedTaskbox}"
selectionMode="single" rowKey="#{task_toUser.ID}" emptyMessage="" paginatorPosition="bottom"
>
<p:ajax event="rowSelect" update=":contentForm, :postForm:tabViewPosts:trashTable, :postForm:tabViewPosts:inboxTable, :postForm:tabViewPosts:sentTable "
listener="#{taskboxBean.onTaskboxRowSelect}" />
<p:column headerText="Post" filterBy="FROM_USER.FIRST_NAME" filterMatchMode="contains">
<h:outputText
value="#{task_toUser.TASKBOX.FROM_USER.FIRST_NAME} #{task_toUser.TASKBOX.FROM_USER.LAST_NAME} (#{task_toUser.TASKBOX.FROM_USER.EMAIL})" />
<p:commandButton disabled="true" style="float:right" icon="ui-icon-mail-closed" rendered="#{!task_toUser.IS_SEEN}"/>
<p:commandButton disabled="true" style="float:right" icon="ui-icon-mail-open" rendered="#{task_toUser.IS_SEEN}"/>
<br/>
<h:outputText value="#{task_toUser.TASKBOX.TASKTYPE.NAME} " />
<h:outputText style="font-weight: bold; " value="#{task_toUser.TASKBOX.TASKBOX_SUPPLIER.NEW_SUPPLIER.NAME}"/>
<br />
<h:outputText value="#{task_toUser.TASKBOX.CREATE_TIMESTAMP}" />
</p:column>
</p:dataTable>
i solved the problem. The problem is that the ArrayList is from another Type than the Selection and xhtml casted it automatically.
Related
I need to export datatable row expansion in primefaces but i cannot figure it out. Is there anyway to do that ?
Thanks in advance.
You can export PrimeFaces DataTable with rowExpansion data without an other Java API or you can use custom export method on ManagedBean class with Apache POI API help.
Here trick is, add the columns which to be exporting to the file and append the visible=”false” attribute to the these columns.
Then append the exportable=”false” attribute to the p:rowToggler column.
Thus, you won’t see datatable columns but you will see these columns on the exported file.
Obtained from here
<h:form id="myDtTblFrm">
<h:commandLink>
<img src="../ims/excel.png"/>
<p:dataExporter type="xlsx" target="myTbl" fileName="myExcelFile"/>
</h:commandLink>
<p:dataTable id="myTbl" var="item" value="#{myBean.list}">
<p:rowExpansion>
<p:panelGrid columns="2" columnClasses="label, value" style="width: 50%">
<h:outputText value="Column Header 04" />
<h:outputText value="#{item.property04}" />
<h:outputText value="Column Header 05" />
<h:outputText value="#{item.property05}" />
</p:panelGrid>
</p:rowExpansion>
<p:column exportable="false">
<p:rowToggler />
</p:column>
<p:column headerText="Colum01">
<p:outputLabel value="#{item.property01}" />
</p:column>
<p:column headerText="Column02" visible="false" >
<p:outputLabel value="#{item.property02}" />
</p:column>
<p:column headerText="colum03" >
<p:outputLabel value="#{item.property03}" />
</p:column>
<p:column headerText="colum04" style="display: none">
<p:outputLabel value="#{item.property04}" />
</p:column>
<p:column headerText="colum05" style="display: none">
<p:outputLabel value="#{item.property05}" />
</p:column>
</p:dataTable>
I want to show the data from an DataList in one row. Here is a picture to show what I want to do https://www.dropbox.com/s/p7pcn67bt0304lo/pic.JPG
I use primefaces 4.0 and jsf 2.1
<p:dataTable id="sentTable" var="task" value="#{taskboxBean.taskboxSentList}" paginator="true"
rows="5" selection="#{taskboxBean.selectedTaskbox}" selectionMode="single" rowKey="#{task.ID}"
paginatorPosition="bottom" emptyMessage="">
<p:ajax event="rowSelect"
update=":contentForm, :postForm:tabViewPosts:trashTable, :postForm:tabViewPosts:inboxTable, :postForm:tabViewPosts:sentTable"
listener="#{taskboxBean.onTaskboxRowSelect}" />
<p:column headerText="Post">
<p:dataGrid var="task_to_user" value="#{task.TASKBOX_TO_USERS}" emptyMessage="Keine Daten">
<p:scrollPanel>
<p:outputLabel
value="#{task_to_user.USER.FIRST_NAME} #{task_to_user.USER.LAST_NAME} #{task_to_user.USER.EMAIL}" />
</p:scrollPanel>
</p:dataGrid>
<h:outputText value="#{task.TASKTYPE.NAME}" />
<br />
<h:outputText value="#{task.CREATE_TIMESTAMP}" />
</p:column>
</p:dataTable>
try This
<p:dataGrid var="task_to_user" value="#{task.TASKBOX_TO_USERS}" emptyMessage="Keine Daten" rows="1" />
Assigning 1 row only
Please help me to find a example to update p:inputtext with data stored in a bean which is set(solved already) by selecting a row of a datatable of a p:dialog. I have succeeded updating outputtext in the same manner.
I am using (learning) netbeans 7.2 primefaces 3.2, glassfish 3.1
thansk for all your help
rs_ncs
Look at primefaces showcase and the user guide, you'll find everything you need; in detail search for rowSelect event for the datatable component. Good luck =)
If you would like to update a component on select of a row from a datatable, then you can use the update attribute of a <p:ajax> which is listening on rowselect event. Something like this:
<p:ajax event="rowSelect" update=":xx:xx" />
As Suggested by BalusC the code <p:ajax event="rowSelect" update=":xx:xx" /> should work....
Here is an example of updating both inputtext and outputtext .
<h:form>
<p:dataTable id="usertable" var="user" value="#{userManageBean.userList}"
rowKey="#{user.U_ID}" selection="#{userManageBean.selectedUser}"
selectionMode="single" paginator="true" rows="18" >
<p:ajax event="rowSelect" update=":useredit:edituser" />
<p:ajax event="rowSelect" update=":viewuser:displayuser" />
<p:column headerText="User Name">
<h:outputText value="#{user.username}" />
</p:column>
<p:column headerText="FName">
<h:outputText value="#{user.firstname}" />
</p:column>
<p:column headerText="LName">
<h:outputText value="#{user.lastname}" />
</p:column>
</p:dataTable>
</h:form>
<p:dialog id="userview" header="View User" widgetVar="dlg2" >
<h:form id="viewuser">
<h:panelGrid id="displayuser" columns="2" cellpadding="4">
<h:outputText value="User Name:" />
<h:outputText value="#{userManageBean.selectedUser.username}" />
<h:outputText value="First Name" />
<h:outputText value="#{userManageBean.selectedUser.firstname}" />
<h:outputText value="Last Name:" />
<h:outputText value="#{userManageBean.selectedUser.lastname}" />
</h:panelGrid>
</h:form>
</p:dialog>
<p:dialog id="user_edit" header="Edit User" widgetVar="dlgedit" >
<h:form id="useredit">
<h:panelGrid id="edituser" columns="2" cellpadding="4">
<h:outputText value="First Name" />
<h:inputText value="#{userManageBean.selectedUser.firstname}" />
<h:outputText value="Last Name" />
<h:inputText value="#{userManageBean.selectedUser.lastname}" />
<p:commandButton id="updateUser" value="Add" action="#{someaction}"
ajax="false" />
</h:panelGrid>
</h:form>
</p:dialog>
I've been running Primefaces 3.0, no issues, and now am trying an upgrade to 3.4.x - I've tried 3.4, 3.4.1, and 3.4.2 and this problem occurs in all 3 - basically for the datatable with the selectionMode="single" option when I click on a row it remains selected no matter how many other rows I select. At the same time I'm quite sure the selection="#{databrowser.selectedData}" variable is not being set when I'm clicking on the rows. The table is fully populated and no 2 rows have the exact same data in all columns. Tested and this occurs in both Chrome and Firefox. I can't find any similar problem posted - wondering if anyone else has had this issue?
Apart from the element referencing this is the 3.0 code I've used:
<p:layoutUnit position="center" resizable="true" header="Data Set Details" styleClass="east_panel_header" >
<h:form id="tblbrowser">
<p:dataTable id="dataTable" emptyMessage="No data sets found." style="width: 100%" var="datlis" resizableColumns="true" value="#{databrowser.selectedDataModel}" widgetVar="dataTable" selection="#{databrowser.selectedData}" selectionMode="single" >
<p:ajax event="rowSelect" update=":usercomments:commentsTable, :tblbrowser:dataTable" />
<f:facet name="header" >
<p:outputPanel>
<h:outputText value="Search all fields " />
<p:inputText id="globalFilter" onkeyup="dataTable.filter()"/>
</p:outputPanel>
</f:facet>
<p:column id="owner" filterBy="#{datlis.uname}" headerText="Added By" filterMatchMode="contains" >
<h:outputText value="#{datlis.uname}" />
</p:column>
<p:column id="name" filterBy="#{datlis.name}" headerText="Name" >
<h:outputText value="#{datlis.name}" />
</p:column>
<p:column id="description" filterBy="#{datlis.description}" headerText="Description" filterMatchMode="endsWith" >
<h:outputText value="#{datlis.description}" />
</p:column>
<p:column id="datatype" filterBy="#{datlis.data_type}" headerText="Data Type"
filterOptions="#{databrowser.dataTypeOptions}" filterMatchMode="exact" >
<h:outputText value="#{datlis.data_type}" />
</p:column>
<p:column id="quality" filterBy="#{datlis.quality}" headerText="Source Type"
filterOptions="#{databrowser.qualityOptions}" filterMatchMode="exact" >
<h:outputText value="#{datlis.quality}" />
</p:column>
<p:column id="added" headerText="Date Added" filterMatchMode="endsWith" >
<h:outputText value="#{datlis.added}" />
</p:column>
<p:column headerText="Metadata" style="width:40px" >
<p:commandButton id="selectButton" rendered="#{datlis.has_metadata}" icon="ui-icon-circle-arrow-s" title="View" ajax="false" >
<f:param name="filepath" value="#{datlis.filepath}" />
<p:fileDownload value="#{filedownloader.mfile}" />
</p:commandButton>
</p:column>
<p:column headerText="Data File(s)" style="width:90px" >
<p:commandButton id="selectButton2" rendered="#{datlis.has_datafiles}" icon="ui-icon-circle-arrow-s" title="View" ajax="false" >
<f:param name="datafiles" value="#{datlis.datafiles}" />
<p:fileDownload value="#{filedownloader2.dfile}" />
</p:commandButton>
<h:outputText value=" " />
<h:outputText value="#{datlis.zipsize}" />
</p:column>
</p:dataTable>
</h:form>
</p:layoutUnit>
You are missing the rowKey attribute which should be the unique identifier of each row.
Example, if your selectedData object has a unique field id, your dataTable component should look like:
<p:dataTable id="dataTable" rowKey=#{datlis.id}
value="#{databrowser.selectedDataModel}" var="datlis"
selection="#{databrowser.selectedData}" selectionMode="single" >
No need to update the same table within p:ajax to see the selection, so you can probably remove the :tblbrowser:dataTable from the update target and have only:
<p:ajax event="rowSelect" update=":usercomments:commentsTable" />
I have problem with datatable using Primefaces 2.2.1 and JSF 2.0.
I have used filtering and paging in the datatable. When I try to filter the selected data is displayed and when i remove the filter the entire data is displayed. But after this when i try to use paging then suddendly all the rows becomes blank(empty)
See screenshot below
Any suggestions. Please help.
.xhtml file
<p:dataTable var="user" value="#{userManagedBean.searchUsersResults}"
selection="#{userManagedBean.selectedUser}" selectionMode="single"
dynamic="true"
onRowSelectUpdate="userUpdateForm"
onRowUnselectUpdate="userUpdateForm"
rowSelectListener="#{userManagedBean.onUserSelect}"
rowUnselectListener="#{userManagedBean.onUserUnselect}"
paginator="true" rows="10" style="width: 70% ">
<p:column sortBy="#{user.userId}" filterBy="#{user.userId}" >
<f:facet name="header">
<h:outputText value="Id" />
</f:facet>
<h:outputText value="#{user.userId}" />
</p:column>
<p:column sortBy="#{user.username}" filterBy="#{user.username}">
<f:facet name="header">
<h:outputText value="Name" />
</f:facet>
<h:outputText value="#{user.username}" />
</p:column>
<p:column sortBy="#{user.emailId}" filterBy="#{user.emailId}">
<f:facet name="header">
<h:outputText value="Email" />
</f:facet>
<h:outputText value="#{user.emailId}" />
</p:column>
<p:column sortBy="#{user.dob}" filterBy="#{user.dob}">
<f:facet name="header">
<h:outputText value="DOB" />
</f:facet>
<h:outputText value="#{user.dob}" >
<f:convertDateTime pattern="MM/dd/yyyy" />
</h:outputText>
</p:column>
</p:dataTable>
<p:panel id="userDetailsPanelId" header="Users Details" style="width:60%;">
<h:panelGrid columns="2" cellpadding="2" id="userUpdateForm" border="0" >
<h:outputLabel for="#{userManagedBean.selectedUser.userId}" value="UserId"/>
<h:inputText value="#{userManagedBean.selectedUser.userId}" style="width: 100%;" readonly="true"></h:inputText>
<h:outputLabel for="#{userManagedBean.selectedUser.username}" value="Username"/>
<h:inputText value="#{userManagedBean.selectedUser.username}" readonly="true"></h:inputText>
<h:outputLabel for="#{userManagedBean.selectedUser.emailId}" value="EmailId"/>
<h:inputText value="#{userManagedBean.selectedUser.emailId}" readonly="true"></h:inputText>
<h:outputLabel for="#{userManagedBean.selectedUser.gender}" value="Gender"/>
<h:inputText value="#{userManagedBean.selectedUser.gender}" readonly="true"></h:inputText>
<h:outputLabel for="#{userManagedBean.selectedUser.dob}" value="DOB"/>
<h:inputText value="#{userManagedBean.selectedUser.dob}" readonly="true">
<f:convertDateTime pattern="MM/dd/yyyy" />
</h:inputText>
</h:panelGrid>
</p:panel>
</h:form>
</center>
I encountered the same problem and eventually discovered it was caused by my value object (in this case your user object) not implementing Serializable.
I'm pretty sure that this known issue has been resolved in both the 2.2.RC and the 2.2 final. I suggest updating your jar file.