views:

9

answers:

1

I am very new to seam, I need some clarification in this below code , I need to know how it works, what is use of RESTRICTIONS in this code .......

package org.domain.pixel.action;

import org.domain.pixel.entity.*; import org.jboss.seam.annotations.Name; import org.jboss.seam.framework.EntityQuery; import java.util.Arrays;

@Name("projectList") public class ProjectList extends EntityQuery {

private static final long serialVersionUID = -7673337640345325071L;

private static final String EJBQL = "select project from Project project";

private static final String[] RESTRICTIONS = { "lower(project.processOwner) like lower(concat(#{projectList.project.processOwner},'%'))", "lower(project.projectName) like lower(concat(#{projectList.project.projectName},'%'))",

};

private Project project = new Project();

public ProjectList() { ; setEjbql(EJBQL); setRestrictionExpressionStrings(Arrays.asList(RESTRICTIONS)); setMaxResults(25); }

public Project getProject() { return project; } }

A: 

The code you posted is a standard approach in Seam to create a backing bean (or "action") for views that are list-based. The ProjectList creates a result set based on the JPA query (called "EJBQL"), and the restrictions are a a means to dynamically create a WHERE clause for this query, for instance based on user input.

The user input is most likely placed in the instance var called "project". The restrictions (2 in total) select only records (from the table corresponding to the Project entity class) for which the processOwner AND the projectName are equal to the processOwner AND the projectName set in "project" (based on a case-insensitive comparison).

Paul