Primefaces 2.2

UI Components for JSF
Post Reply
User avatar
gmaldonadonaval
Posts: 6
Joined: 01 Dec 2010, 03:53
Location: Mexico, Jalisco, Guadalajara

05 Dec 2010, 02:44

Hi everyone,
I created a page to list some records, but this is a first test of the datatable component, then y filled the managebean with the records to be showed in the datatable an d all works fine, but when I triyed to change the page from the paginator I got this error:

Code: Select all

<?xml version='1.0' encoding='UTF-8'?>
<partial-response><changes><update id="javax.faces.ViewState"><![CDATA[7131270948745700473:3012885566361031156]]></update></changes><extension primefacesCallbackParam="validationFailed">{"validationFailed":false}</extension></partial-response>
The xhtml code:

Code: Select all

<?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">

<f:view xmlns="http://www.w3.org/1999/xhtml"
		xmlns:f="http://java.sun.com/jsf/core"
		xmlns:h="http://java.sun.com/jsf/html"
		xmlns:ui="http://java.sun.com/jsf/facelets"
		xmlns:p="http://primefaces.prime.com.tr/ui">
	<html>
		<h:head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
		<title>Prueba con Primefaces</title>
	</h:head>
		<h:body>
		<h1 class="title ui-widget-header ui-corner-all">#{appScreen['screen.customer.admin.user.title.label']}</h1>
		<br />
		<h:form id="formCriteria">
			<p:fieldset>
				<!-- <div class="entry"> -->
					<table>
						<tbody>
							<tr>
								<td>
									<h:outputLabel for="user" value="#{appScreen['screen.customer.admin.user.criteria.user.label']}"
												   maxlength="12" size="15" 
									               validator="#{mBAccountUsersValidator.validateUser}">
									</h:outputLabel>
								</td>
								<td><h:inputText id="user" maxlength="13" size="15"	value="#{mBAccountUsers.criteria.user}"/></td>
								
								<td><h:outputLabel for="status" value="#{appScreen['screen.customer.admin.user.criteria.status.label']}"></h:outputLabel></td>
								<td>
									<h:selectOneMenu id="status" value="#{mBAccountUsers.criteria.status}">
										<f:selectItems value="#{mBAccountUsers.statusItems}"/>
									</h:selectOneMenu>
								</td>
							</tr>
							<tr>
								<td colspan="2"><p:message for="user" /></td>
								<td colspan="2"><p:message for="status" /></td>
							</tr>
						</tbody>
						
					</table>
				</p:fieldset>
					<p:commandButton actionListener="#{mBAccountUsers.actionSearch}" ajax="false" update="list" 
					                 value="#{appScreen['screen.customer.admin.user.criteria.cmdSearch.label']}"></p:commandButton>
					<p:commandButton actionListener="#{mBAccountUsers.actionClear}"  ajax="true"  update="content" 
					                 value="#{appScreen['screen.customer.admin.user.criteria.cmdCancel.label']}"></p:commandButton>
					<p:messages globalOnly="true" showDetail="true" />
				<!-- </div> -->
			
			
		
				<div class="list">
				<p:dataTable id="UserListTest" var="users" value="#{mBAccountUsers.list}" rendered="#{mBAccountUsers.showList}" paginator="true"
					rows="10" update="content" 
					paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
					rowsPerPageTemplate="5,10,15" 
					selectionMode="single"
					selection="#{mBAccountUsers.recordSelected}"
					dblClickSelect="true"
					rowSelectListener="#{mBAccountUsers.onRowSelect}">
					<f:facet name="header">#{appScreen['screen.customer.admin.user.list.header.label']}</f:facet>
			
					<p:column sortBy="#{users.user}" filterBy="#{users.user}" footerText="contains" filterMatchMode="contains">
						<f:facet name="header">
							<h:outputText value="#{appScreen['screen.customer.admin.user.list.field.header.user.label']}" />
						</f:facet>
						<h:outputText value="#{users.user}" />
					</p:column>
			
					<p:column sortBy="#{users.name}" filterBy="#{users.name}" footerText="contains" filterMatchMode="contains">
						<f:facet name="header">
							<h:outputText value="#{appScreen['screen.customer.admin.user.list.field.header.name.label']}" />
						</f:facet>
						<h:outputText value="#{users.name}" />
					</p:column>
			
					<p:column sortBy="#{users.middleName}" filterBy="#{users.middleName}" footerText="contains" filterMatchMode="contains">
						<f:facet name="header">
							<h:outputText value="#{appScreen['screen.customer.admin.user.list.field.header.middleName.label']}" />
						</f:facet>
						<h:outputText value="#{users.middleName}" />
					</p:column>
			
					<p:column sortBy="#{users.lastName}" filterBy="#{users.lastName}" footerText="contains" filterMatchMode="contains">
						<f&#58;facet name="header">
							<h:outputText value="#{appScreen['screen.customer.admin.user.list.field.header.lastName.label']}" />
						</f:facet>
						<h:outputText value="#{users.lastName}" />
					</p:column>
					
					<p:column sortBy="#{users.rolId}" filterBy="#{users.rolId}" filterOptions="#{mBAccountUsers.rolItems}" filterMatchMode="exact">
						<f:facet name="header">
							<h:outputText value="#{appScreen['screen.customer.admin.user.list.field.header.rol.label']}" />
						</f:facet>
						<h:outputText value="#{users.rolId}" />
					</p:column>
					
					<p:column sortBy="#{users.status}" filterBy="#{users.status}"  filterOptions="#{mBAccountUsers.statusItems}" filterMatchMode="exact">
						<f:facet name="header">
							<h:outputText value="#{appScreen['screen.customer.admin.user.list.field.header.status.label']}" />
						</f:facet>
						<h:outputText value="#{users.status}" />
					</p:column>
					
				</p:dataTable>
				</div>
		
		</h:form>
		</h:body>
	</html>
</f:view>
Manage Bean

Code: Select all

package com.malcor.tax.receip.web.admin;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;
import javax.faces.event.ActionEvent;
import javax.faces.model.SelectItem;

import org.primefaces.event.SelectEvent;

import com.malcor.ereceip.data.constants.CatUserStatusConstants;
import com.malcor.ereceip.logic.receip.vo.AccountUsersVo;
import com.malcor.tax.receip.web.common.mbeans.TaxReceipMantManageBean;

@ManagedBean
@RequestScoped
public class MBAccountUsers extends TaxReceipMantManageBean<AccountUsersVo,AccountUsersVo,AccountUsersVo> implements Serializable {
	/** Criterio de busqueda
	private AccountUsersVo criteria = new AccountUsersVo(); */
	/** Lista de usuarios 
	private List<AccountUsersVo> userList = new ArrayList<AccountUsersVo>();*/
	/** Bandera para controlar cuando se muestra el listado */
	private boolean showList = Boolean.FALSE;
	/** rol */
	private List<SelectItem> rolItems;
	/** Status */
	private List<SelectItem> statusItems;

	public MBAccountUsers() {
		loadCatalogs();
	}

	private void loadCatalogs() {
		this.rolItems = new ArrayList<SelectItem>();
		this.rolItems.add(new SelectItem("0", "Seleccione una opción"));
		this.rolItems.add(new SelectItem("1", "Administrador"));
		this.rolItems.add(new SelectItem("2", "Facturador"));

		this.statusItems = new ArrayList<SelectItem>();
		this.statusItems.add(new SelectItem(CatUserStatusConstants.DEFAULT
				.name(), "Seleccione una opción"));
		this.statusItems.add(new SelectItem(CatUserStatusConstants.ACTIVE
				.name(), "Activo"));
		this.statusItems.add(new SelectItem(CatUserStatusConstants.DELETED
				.name(), "Eliminado"));
		this.statusItems.add(new SelectItem(
				CatUserStatusConstants.LOCKED_FORGOTT.name(),
				"Bloqueo por reactivación"));
		this.statusItems.add(new SelectItem(CatUserStatusConstants.LOCKED_PASS
				.name(), "Bloqueo por intentos incorrectos"));
		this.statusItems.add(new SelectItem(CatUserStatusConstants.SUSPENDED
				.name(), "Suspendido"));
	}

	/**
	 * 
	 * @param action
	 */
	public void actionSearch(ActionEvent action) {
		super.setList(new ArrayList<AccountUsersVo>());

		for (int cont = 0; cont < 20; cont++) {
			AccountUsersVo user = new AccountUsersVo();
			user.setUserId(Integer.toString(cont));
			user.setUser("gmaldonado" + cont);
			user.setName("Gus " + cont);
			user.setMiddleName("Maldonado " + cont);
			user.setLastName("Naval " + cont);
			user.setRolId("Administrador");
			user.setStatusId("1");
			user.setStatus(CatUserStatusConstants.ACTIVE);
			super.getList().add(user);
		}
		showList = Boolean.TRUE;
	}

	public void onRowSelect(SelectEvent event) {
		
	}

	
	public void onRowSelectNavigate(SelectEvent event) {
		
	}

	/**
	 * 
	 * @param action
	 */
	public void actionClear(ActionEvent action) {
		this.setList(new ArrayList<AccountUsersVo>());
		showList = Boolean.FALSE;
	}
	/**
	public AccountUsersVo getCriteria() {
		return criteria;
	}

	public void setCriteria(AccountUsersVo criteria) {
		this.criteria = criteria;
	}

	public List<AccountUsersVo> getUserList() {
		return userList;
	}

	public AccountUsersVo[] getUserList2() {
		return (AccountUsersVo[]) userList.toArray();
	}

	public void setUserList(List<AccountUsersVo> userList) {
		this.userList = userList;
	}*/

	public SelectItem[] getRolItems() {
		SelectItem[] array = new SelectItem[]{};
		return rolItems.toArray(array);
	}

	public void setRolItems(List<SelectItem> rolItems) {
		this.rolItems = rolItems;
	}

	public SelectItem[] getStatusItems() {
		SelectItem[] array = new SelectItem[]{};
		return statusItems.toArray(array);
	}

	public void setStatusItems(List<SelectItem> statusItems) {
		this.statusItems = statusItems;
	}

	public boolean isShowList() {
		return showList;
	}

	public void setShowList(boolean showList) {
		this.showList = showList;
	}

}

VO object

Code: Select all

package com.malcor.ereceip.logic.receip.vo;

import java.io.Serializable;

import com.malcor.ereceip.data.constants.CatUserStatusConstants;

public class AccountUsersVo implements Serializable {
	
	/**
	 * 
	 */
	private static final long serialVersionUID = 7334845151157423070L;
	private String accountId;
	private String userId;
	
	private String user;
	private String pwd;
	private String name;
	private String middleName;
	private String lastName;
	private String rolId;
	private String statusId;
	private CatUserStatusConstants status;
	
	public String getAccountId() {
		return accountId;
	}
	public void setAccountId(String accountId) {
		this.accountId = accountId;
	}
	public String getUserId() {
		return userId;
	}
	public void setUserId(String userId) {
		this.userId = userId;
	}
	public String getUser() {
		return user;
	}
	public void setUser(String user) {
		this.user = user;
	}
	public String getPwd() {
		return pwd;
	}
	public void setPwd(String pwd) {
		this.pwd = pwd;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public String getMiddleName() {
		return middleName;
	}
	public void setMiddleName(String middleName) {
		this.middleName = middleName;
	}
	public String getLastName() {
		return lastName;
	}
	public void setLastName(String lastName) {
		this.lastName = lastName;
	}
	public String getRolId() {
		return rolId;
	}
	public void setRolId(String rolId) {
		this.rolId = rolId;
	}
	public String getStatusId() {
		return statusId;
	}
	public void setStatusId(String statusId) {
		this.statusId = statusId;
	}
	public CatUserStatusConstants getStatus() {
		return status;
	}
	public void setStatus(CatUserStatusConstants status) {
		this.status = status;
	}
	
	@Override
	public boolean equals(Object obj) {
		if(obj == null)
			return false;
		
		if(!(obj instanceof AccountUsersVo))
			return false;
		
		AccountUsersVo compare = (AccountUsersVo) obj;
	
		return compare.accountId.equals(this.accountId);
	}

	@Override
	public int hashCode() {
		int hash = 1;
		
	    return hash * 31 + accountId.hashCode();
	}	
}


I do some test for example:
  • 1.-Change to the version Primefaces 2.2 M1 snapshot and I got the same.
    2.-Change to the version Primefaces 2.1 and the datatable works fine but didn't show the skin of the table.
    3.-Change to the version Primefaces 2.0.2 and the datatable works fine but didn't show the skin of the table.
I think is a bug in the version 2.2 but some know how fix it ?


I'm using:
Eclipse Helios
primefaces2.2 RC2
Moharra 2.0.3
Tomcat 6
JSF 2
Java 6
IE 8
Firefox
Regards
Autobot
Java Architect
Primefaces 2.2 RC2, Mojarra 2.0.3, Tomcat 6.0, JSF 2.0

callahan
Posts: 768
Joined: 27 May 2010, 22:52

05 Dec 2010, 15:53

The following states that validationFailed == false, which means that everything is ok :!:.

Code: Select all

<?xml version='1.0' encoding='UTF-8'?>
<partial-response><changes><update id="javax.faces.ViewState"><![CDATA[7131270948745700473:3012885566361031156]]></update></changes><extension primefacesCallbackParam="validationFailed">{"validationFailed":false}</extension></partial-response>

ethermion
Posts: 117
Joined: 25 Aug 2010, 15:11

05 Dec 2010, 18:05

Not sure it is your problem, but I would make the managed bean view scoped, given that you are using a paginator. The paginator is expecting the same dataset, which is now destroyed given the request scope. Who knows what it is doing.

Datatable is a complete re-write in 2.2. Comparing to 2.1 behavior holds no clues for you.

-e
Mojarra 2.2.8
Primefaces 5.1
Wildfly 8.2

User avatar
gmaldonadonaval
Posts: 6
Joined: 01 Dec 2010, 03:53
Location: Mexico, Jalisco, Guadalajara

05 Dec 2010, 20:39

In this example I want to do a List of records in a datatable, I based my example in the PRIMEFACES-Showcase, I copied all the jars from that example and I created my own facelets, I made a Logon form and works very well, but when a made the prototype of a list with datatable the AJAX failed, the pagination didn't work.

At the beggining I belive I was doing wrong but when I changed to previus versions of Primefaces this works partially.

I know I didn't put a DAO or services of Spring because I want made first the prototipe.

Thanks for your help
Autobot
Java Architect
Primefaces 2.2 RC2, Mojarra 2.0.3, Tomcat 6.0, JSF 2.0

User avatar
gmaldonadonaval
Posts: 6
Joined: 01 Dec 2010, 03:53
Location: Mexico, Jalisco, Guadalajara

05 Dec 2010, 21:54

I found the error, ethermion was correct, I needs change the scope of the manage bean to SESSION, sorry for loss your time with this issue, but maybe helpfull if the error give more information about the error.

thanks in advance
Autobot
Java Architect
Primefaces 2.2 RC2, Mojarra 2.0.3, Tomcat 6.0, JSF 2.0

ethermion
Posts: 117
Joined: 25 Aug 2010, 15:11

05 Dec 2010, 22:20

No worries. Help around here, like Primefaces is free.

Glad you got it fixed,

-e
Mojarra 2.2.8
Primefaces 5.1
Wildfly 8.2

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 31 guests