× Please, log in to give us a feedback. Click here to login

You must be logged to download. Click here to login


MrBool is totally free and you can help us to help the Developers Community around the world

Yes, I'd like to help the MrBool and the Developers Community before download

No, I'd like to download without make the donation


MrBool is totally free and you can help us to help the Developers Community around the world

Yes, I'd like to help the MrBool and the Developers Community before download

No, I'd like to download without make the donation

Advanced Searching with Seam framework

Seam provides some facilities of Advanced Searching. This article will discuss about Advanced Searching with Seam framework.

Seam provides some facilities of Advanced Searching. We all know that Seam is a strong component based framework. Searching is very important for any framework.

There are many frameworks, which allow implement their first crack at content searching. It works independently but does not give the search experience users expect today. However, seam can provide a specific searching component. For example, if the search query is computer software and the blog contains text or other like "what we supply both by the parameter computers and software", the normal like query that will not work, because of the word and is in the middle point. Therefore, trying to solve such kind of problems with complex type of SQL constructions becomes a nightmare and gives poor results. SEAM provides even worse and these types of like-based queries that have severe performance problems as the data set grows, because it does not use any type of indexing. It must search through the entire corpus, one character at a time.

Seam integrates many technologies like JavaScript, JSP, JSTL, Ajax, JPA, JBPM and servlet. Seam is an application development framework for Java EE that connected the component and other models of JSF and EJB 3.0 that is a strong component dependent framework, providing a streamlined searching model for web-based java and j2ee enterprise applications.

Listing 1: JSP code:

package com.domtech.domain.config;
import java.math.BigDecimal;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import org.hibernate.validator.Length;
import org.hibernate.validator.NotNull;
import org.jboss.seam.annotations.Name;
@Table(name = "ADMIN_UNION")
public class AdminUnion implements java.io.Serializable {
	private long unionId;
	private AdminUpazila adminUpazila;
	private String unionNameEng; 
     public AdminUnion() {
public AdminUnion(long unionId, AdminUpazila adminUpazila) {
		this.unionId = unionId;
		this.adminUpazila = adminUpazila;
	public AdminUnion(long unionId, AdminUpazila adminUpazila
) {
		this.unionId = unionId;
		this.adminUpazila = adminUpazila;
		this.unionNameEng = unionNameEng;	
	@Column(name = "UNION_ID", unique = true, nullable = false, precision = 20, scale = 0)
	public long getUnionId() {
		return this.unionId;
	public void setUnionId(long unionId) {
		this.unionId = unionId;
      @Column(name = "UNION_NAME_ENG", length = 250)
	@Length(max = 250)
	public String getUnionNameEng() {
		return this.unionNameEng;
public void setUnionNameEng(String unionNameEng) {
		this.unionNameEng = unionNameEng;

Now we will show the ‘AdpSectorList’, which extends ‘EntityQuery’. The ‘EntityQuery’ execute a tremendous searching option with the help of xml and xhtml. The connection with entity, List property class, xml and xhtml provide the excellent facility of Advanced Searching by using SEAM framework.

Listing 2: AdpSectorList:

package com.domtech.service.adp.adpSector;
import org.jboss.seam.annotations.Name;
import org.jboss.seam.framework.EntityQuery;
import com.domtech.domain.adp.AdpSector;
import com.domtech.ejb.util.Constants;
import java.util.Arrays;
public class AdpSectorList extends EntityQuery<AdpSector> {
	private static final String EJBQL = "select adpSector from AdpSector adpSector order by adpSector.serialPriority ASC";
    private static final String[] RESTRICTIONS = {
			"lower(adpSector.sectorNameEng) like lower(concat(#{adpSectorList.adpSector.sectorNameEng},'%'))",
			"lower(adpSector.sectorNameBen) like lower(concat(#{adpSectorList.adpSector.sectorNameBen},'%'))",
			"lower(adpSector.statusInfo) like lower(concat(#{adpSectorList.adpSector.statusInfo},'%'))", };

	private AdpSector adpSector = new AdpSector();
       public AdpSectorList() {
	public AdpSector getAdpSector() {
		return adpSector;

We will provide a sample example how seam framework enable searching facilities. For this reason, we will provide the code sincere gradually. Seam framework generates the entities and this entity connects with ‘Entity Query’. Which provide a excellent feature of searching with the help of ‘xml’ and ‘xhtml’. We know ‘xhtml’ is a case sensitive markup language. So we should be careful when we are going to coding with it. Therefore, Seam works with JBoss and j2ee. BY using Seam framework, we can bind our EJB components directly to JSF pages, so we do not need to go through any kind of XML configuration for that.

Now we will preview the xml, which connect and make interlink with Java action and presentation layer. In addition, Seam provides all the quick outlook of it.

Listing 3: XML code:

<?xml version="1.0" encoding="UTF-8"?>
<page xmlns="http://jboss.com/products/seam/pages"
      xsi:schemaLocation="http://jboss.com/products/seam/pages http://jboss.com/products/seam/pages-2.2.xsd">
   Round List: #{adminSectorList.resultList.size} of #{adminSectorList.resultCount}
  <begin-conversation join="true"/>
   <param name="firstResult" value="#{adminSectorList.firstResult}"/>
   <param name="sort" value="#{adminSectorList.orderColumn}"/>
   <param name="dir" value="#{adminSectorList.orderDirection}"/>
   <param name="logic" value="#{adminSectorList.restrictionLogicOperator}"/>

   <param name="from"/>
   <param name="sectorNameEng" value="#{adminSectorList.adminSector.sectorNameEng}"/>
   <param name="sectorNameBen" value="#{adminSectorList.adminSector.sectorNameBen}"/>
   <param name="statusInfo" value="#{adminSectorList.adminSector.statusInfo}"/>

Now we present the presentation layer of advanced Searching, which come to be true by the help of XHTML page that call a markup language page.

Listing 4: Presentation layer of advanced Searching:

<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
<ui:composition xmlns="http://www.w3.org/1999/xhtml"

<ui:define name="body">
<a4j:form id="Search" ajaxSubmit="true"  reRender="dataPanel">
<a4j:commandButton value="Create Sector" action="#{sectorManager.createSector}" oncomplete="javascript:Richfaces.showModalPanel('editPanel')"
reRender="frmDiv" style="width:100px"> 
 <a4j:outputPanel id="dataPanel" ajaxRendered="true">
        <rich:simpleTogglePanel label=" Sector Search Filter" switchType="ajax">
        <f:facet name="openMarker" >
        	<h:graphicImage url="/img/down.gif"/>
        <f:facet name="closeMarker" >
        	<h:graphicImage url="/img/up.gif"/>
        <h:outputText id="del" style="font-color:red;" styleClass="delLabel" value="#{sectorManager.msg}"/>
		<h:panelGrid columns="3" columnClasses="searchCol1,searchCol2,searchCol3">
<h:outputLabel value="Sector Name (English)"/>
			<h:outputLabel value=":"/>
            <h:inputText id="sectorNameEng" styleClass="inputField" value="#{adminSectorList.adminSector.sectorNameEng}"/>
<h:outputLabel value="Sector Name (Bangla)"/>
			<h:outputLabel value=":"/>
            <h:inputText id="sectorNameBen" styleClass="inputField" value="#{adminSectorList.adminSector.sectorNameBen}"/>
<h:outputText value="Match"></h:outputText>
		<h:outputText value=":"></h:outputText>
             <h:selectOneRadio id="logic" value="#{adminSectorList.restrictionLogicOperator}" styleClass="radio">
               <f:selectItem itemLabel="All" itemValue="and"/>
               <f:selectItem itemLabel="Any" itemValue="or"/>
<ui:include src="/includes/searchButtons.xhtml"/>  
        <f:facet name="header"> Sector Search Results (#{empty adminSectorList.resultList ? 0 : (adminSectorList.paginated ? adminSectorList.resultCount : adminSectorList.resultList.size)})</f:facet>
    <div class="results" id="adminSectorList">
<h:outputText value="Sector search returned no results."
               rendered="#{empty adminSectorList.resultList}"/>
<rich:dataTable id="adminSectorList"
           rendered="#{not empty adminSectorList.resultList}">
            <f:facet name="header">
                <ui:include src="/includes/sort.xhtml">
                    <ui:param name="entityList" value="#{adminSectorList}"/>
                    <ui:param name="propertyLabel" value="Sector  (English)"/>
                    <ui:param name="propertyPath" value="adminSector.sectorNameEng"/>
            <h:outputText value="#{adminSector.sectorNameEng}"/>
            <f:facet name="header">
                <ui:include src="/includes/sort.xhtml">
                    <ui:param name="entityList" value="#{adminSectorList}"/>
                    <ui:param name="propertyLabel" value="Sector  (Bangla)"/>
                    <ui:param name="propertyPath" value="adminSector.sectorNameBen"/>
            <h:outputText value="#{adminSector.sectorNameBen}"/>
            <f:facet name="header">
                <ui:include src="/includes/sort.xhtml">
                    <ui:param name="entityList" value="#{adminSectorList}"/>
                    <ui:param name="propertyLabel" value="Status"/>
                    <ui:param name="propertyPath" value="adminSector.statusInfo"/>
            <h:outputText value="#{adminSector.statusInfo}"/>
       <rich:column styleClass="action">
            <f:facet name="header">Action</f:facet>
			<a4j:commandLink ajaxSingle="true" id="editlink1"
								action="#{sectorManager.editSectorForm(adminSector)}"  reRender="editPanel,editButton,saveButton"
			<h:outputText value="View" />
            #{' '}
<a4j:commandLink ajaxSingle="true" id="editlink18"
								action="#{sectorManager.editSectorForm_1(adminSector)}"  reRender="editPanel,editButton,saveButton"
			<h:outputText value="Edit" />
    <ui:include src="/includes/pagination.xhtml">
          <ui:param name="entityList" value="#{adminSectorList}"/> 
<rich:modalPanel height="200" id="editPanel" autosized="true" width="600">

			<f:facet name="header">
				<h:outputText value="Sector" styleClass="textTopMenu" />
			<f:facet name="controls">
					<h:graphicImage value="/images/modal/close.png" id="hidelink"
						styleClass="hidelink" />
					<rich:componentControl for="editPanel" attachTo="hidelink"
						operation="hide" event="onclick" />
		<h:form id="frmDiv">
			<h:outputText value="Mandatoryfield ( * )" styleClass="enMandatory"/><br/><br/>
			 <a4j:outputPanel ajaxRendered="true">
				 <h:panelGrid columns="5" columnClasses="colModal1,colModal2, colModal3, colModal4, colModal5" >                  
	                    <h:outputLabel for="engName" value="Sector (English)" styleClass="formLabel"/>
	                    <h:outputText value=":"  />
	                    <h:outputLabel value="*" for="engName" style="color:red"/>	
	                    <h:inputText id="engName" value="#{sector.sectorNameEng}"
	                    	required="true" requiredMessage="#{messages.entervalue}" styleClass="inputField"/>
	                     <rich:message for="engName" style="color:red; font-style:italic;"/>
	                    <h:outputLabel for="banName" value="Sector (Bangla)" styleClass="formLabel"/>
	                    <h:outputText value=":"  />
	                    <h:outputLabel value="*" for="banName" style="color:red"/>	
	                    <h:inputText id="banName" value="#{sector.sectorNameBen}"
	                    	required="true" requiredMessage="#{messages.entervalue}" styleClass="inputField"/>
	                     <rich:message for="banName" style="color:red; font-style:italic;"/>  
                        <h:outputLabel for="activation" value=" Status" styleClass="formLabel"/>
	                    <h:outputText value=":"  />
	                    <h:outputText value="" /> 
	                      <h:selectOneRadio id="activation" value="#{sector.statusInfo}" styleClass="formLabel" style="width:180px;">
	                    	<f:selectItem id="item1" itemLabel="Active" itemValue="Active"/>
  							<f:selectItem id="item2" itemLabel="Inactive" itemValue="Inactive" />
	                    <h:outputText value="" />

				<div align="center">
				<a4j:commandButton value="Save" 
					action="#{sectorManager.addSector(sector)}"	reRender="dataPanel"
					oncomplete="if (#{facesContext.maximumSeverity==null})  #{rich:component('editPanel')}.hide();return false;"
				<a4j:commandButton value="Close" immediate="true" 	
			 			onclick="#{rich:component('editPanel')}.hide();return false;" />					

By the combination of all of this code combination we can able to achieve the feature of advanced searching. By the using of advanced searching option, we can retrieve the data from any database depend on our requirement. This is helpful for any web application of website.

So, the integration of advanced searching option is very powerful scenario of SEAM framework that provides a fast searching among the databases.

Provide screen short of SEAM advanced searching

Figure 1: Provide screen short of SEAM advanced searching.

This is all for this article. See you next time.

My main area of specialization is Java and J2EE. I have worked on many international projects like Recorders,Websites,Crawlers etc.Also i am an Oracle Certified java professional as well as DB2 certified

What did you think of this post?
To have full access to this post (or download the associated files) you must have MrBool Credits.

  See the prices for this post in Mr.Bool Credits System below:

Individually – in this case the price for this post is US$ 0,00 (Buy it now)
in this case you will buy only this video by paying the full price with no discount.

Package of 10 credits - in this case the price for this post is US$ 0,00
This subscription is ideal if you want to download few videos. In this plan you will receive a discount of 50% in each video. Subscribe for this package!

Package of 50 credits – in this case the price for this post is US$ 0,00
This subscription is ideal if you want to download several videos. In this plan you will receive a discount of 83% in each video. Subscribe for this package!

> More info about MrBool Credits
You must be logged to download.

Click here to login