Skip to main content

problem with the datatable in jsf

1 reply [Last post]
arvindporlekar
Offline
Joined: 2010-10-01

i have one problem with datatable.At first time bean load the value and datatable can able to show the values from list.but when i click on button on the same jsp..data table again call the getList method of bean and i am not able to perform the next operation.

search bean :
****************************************
package se.bilprovningen.prippe.web.impl;

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

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import javax.ejb.EJB;
import javax.faces.context.FacesContext;
import javax.faces.model.SelectItem;
import javax.servlet.ServletContext;

import se.bilprovningen.prippe.common.biz.Article;
import se.bilprovningen.prippe.common.biz.Filter;
import se.bilprovningen.prippe.facade.ArticleFacade;
import se.bilprovningen.prippe.facade.exception.PrippeErrorException;
import se.bilprovningen.prippe.facade.exception.PrippeFatalException;
import se.bilprovningen.prippe.web.Search;
import se.bilprovningen.prippe.web.util.FilterFactory;

public class SearchBean implements Serializable, Search {

/**
*
*/
private static final long serialVersionUID = 5112577785724797101L;

@EJB
ArticleFacade articleFacade;
private HashMap articleMap = new HashMap();
private String name;
private String value;

private List propertyList = new ArrayList();
private List articleIdList = new ArrayList();

public HashMap getArticleMap() {
return articleMap;
}

public void setArticleMap(HashMap articleMap) {
this.articleMap = articleMap;
}

public List getArticleIdList() {
return articleIdList;
}

public void setArticleIdList(List articleIdList) {
this.articleIdList = articleIdList;
}

public List getPropertyList() {
return propertyList;
}

public void setPropertyList(List propertyList) {
this.propertyList = propertyList;
}

/* (non-Javadoc)
* @see se.bilprovningen.prippe.web.impl.Search#getName()
*/
public String getName() {
return name;
}

/* (non-Javadoc)
* @see se.bilprovningen.prippe.web.impl.Search#setName(java.lang.String)
*/
public void setName(String name) {
this.name = name;
}

/* (non-Javadoc)
* @see se.bilprovningen.prippe.web.impl.Search#getValue()
*/
public String getValue() {
return value;
}

/* (non-Javadoc)
* @see se.bilprovningen.prippe.web.impl.Search#setValue(java.lang.String)
*/
public void setValue(String value) {
this.value = value;
}

/* (non-Javadoc)
* @see se.bilprovningen.prippe.web.impl.Search#init()
*/

@SuppressWarnings("unchecked")
@PostConstruct
public void init(){

System.out.println("SearchBean Post-Constructed");
setValue("");
//Get Articles from DB and upload the List
List properties = articleFacade.getAllDescriptions();
propertyList = new ArrayList();
if( properties != null && properties.size() > 0 ){

Iterator itr = properties.iterator();
SelectItem firstItm = new SelectItem();
firstItm.setLabel("Select Property");
firstItm.setValue("");
propertyList.add(firstItm);

while( itr.hasNext() ){
SelectItem itm = new SelectItem();
String propertyName = itr.next().toString();
itm.setLabel(propertyName);
itm.setValue(propertyName);
propertyList.add(itm);
}
}
System.out.println("SearchBean Successfully Post-Constructed");
}

/* (non-Javadoc)
* @see se.bilprovningen.prippe.web.impl.Search#destroy()
*/
@PreDestroy
public void destroy(){
System.out.println("SearchBean Pre-Destroyed");

}

/* (non-Javadoc)
* @see se.bilprovningen.prippe.web.impl.Search#doSearch()
*/
@SuppressWarnings("unchecked")
public String doSearch() {
System.out.println("Selected Name:"+getName());
System.out.println("Selected Value:"+getValue());
Filter filter = FilterFactory.getNewInstance(getName(), getValue());
List filterList = new ArrayList();
List filterValues = new ArrayList();
filterList.add(filter);
filterValues.add(getValue());
HashMap map = null;
try {
List articles = articleFacade.findArticles(filterList, filterValues, null, null);
if(articles != null && articles.size()>0){
map = new HashMap();
for(int i=0; i
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>

<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
//Get Search result list
%>

Search Result

function setArticleId(articleId) {
document.getElementById("searchResultForm:hidArticleId").value = articleId;
}

***************************************************************************************

in this jsp if i click on any command button i am not able to go ahead

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
healeyb
Offline
Joined: 2010-01-26

Please sort out the formatting - have you read your own post?