Primefaces dataTable with checkbox not work - checkbox

I am using Primefaces 4.0 with jsf2.2.
When I use dataTable with checkbox, it won't send back any record whenever I select records.
It supposed to send back the record once I click the checkbox.
I remove extra stuff and make my code simple to test it:
There is a polling printing selected items every second, so that I can check is there something sent back.
And after doing this, I found there's nothing sent back.
Here's my code:
Page:
<h:head>
<title>System Monitor</title>
</h:head>
<h:body>
<h:form>
<p:poll interval="1" listener="#{indexBean.printSelect()}"/>
</h:form>
<h:form>
<p:dataTable id='data' var="proc" value="#{indexBean.procStatus}"
rowKey="#{proc.pid}" selection="#{indexBean.selectedProcs}">
<p:column>
<f:facet name='header'>
<h:outputText value='Process Name'/>
</f:facet>
<h:outputText styleClass="outputCell" id="pname" value='#{proc.name}'/>
</p:column>
<p:column selectionMode="multiple"/>
</p:dataTable>
</h:form>
</h:body>
Backing Bean:
#ManagedBean(name = "indexBean")
#ViewScoped
public class indexBean implements Serializable {
private ProcStatDataModel procStatus;
private SingleProcess[] selectedProcs;
#PostConstruct
public void loadProcStat() {
List<SingleProcess> temp = new ArrayList<>();
temp.add(new SingleProcess("test1"));
temp.add(new SingleProcess("test2"));
temp.add(new SingleProcess("test3"));
procStatus = new ProcStatDataModel(temp);
}
public void printSelect() {
if (selectedProcs != null) {
String str = "";
for (SingleProcess sp : selectedProcs) {
str += sp.getName() + "_";
}
System.out.print(str);
} else {
System.out.println("selectedProcs is null");
}
}
public ProcStatDataModel getProcStatus() {
return procStatus;
}
public SingleProcess[] getSelectedProcs() {
return selectedProcs;
}
public void setSelectedProcs(SingleProcess[] selectedProcs) {
this.selectedProcs = selectedProcs;
}
}
I've tried attaching rowCheckListener like this before but in vain.
Also, I tried adding f:view contentType="text/html" like this and it was not help.
It's weird because I do the same thing with the case of primefaces show case and it acts as I think. So I think this approach is OK, there should be something wrong in my code.
Any help is appreciated. Thanks in advance.

I made a few changes and it worked. Not sure, which one is the solution.
1) Changed all the ' to ".
2) Datatable's value="#{indexBean.procStatus}" is wrong i think. I changed it to the name of the ArrayList inside the class. So, it became value="#{indexBean.procStatus.mylist}"
3) Added an ajax listener, like the one you mentioned in the question. <p:ajax event="rowSelectCheckbox" listener="#{indexBean.check}" />.
4) Added pid to the constructor which will be our rowKey.
5) Now, the poll prints the array.
Resultin xhtml is as follows:
<h:head>
<title>System Monitor</title>
</h:head>
<h:body>
<h:form>
<p:poll interval="1" listener="#{indexBean.printSelect()}"/>
</h:form>
<h:form>
<p:dataTable id="data" var="proc" value="#{indexBean.procStatus.mylist}"
rowKey="#{proc.pid}" selection="#{indexBean.selectedProcs}">
<p:ajax event="rowSelectCheckbox" listener="#{indexBean.check}" />
<p:column>
<f:facet name="header">
<h:outputText value="Process Name"/>
</f:facet>
<h:outputText styleClass="outputCell" id="pname" value="#{proc.name}"/>
</p:column>
<p:column selectionMode="multiple"/>
</p:dataTable>
</h:form>
</h:body>
</ui:composition>
Bean:
#ManagedBean(name = "indexBean")
#ViewScoped
public class indexBean implements Serializable {
private ProcStatDataModel procStatus;
private SingleProcess[] selectedProcs;
#PostConstruct
public void loadProcStat() {
List<SingleProcess> temp = new ArrayList<SingleProcess>();
temp.add(new SingleProcess("test1",1));
temp.add(new SingleProcess("test2",2));
temp.add(new SingleProcess("test3",3));
procStatus = new ProcStatDataModel(temp);
}
public void printSelect() {
if (selectedProcs != null) {
String str = "";
for (SingleProcess sp : selectedProcs) {
str += sp.getName() + "_";
}
System.out.print(str);
} else {
System.out.println("selectedProcs is null");
}
}
public ProcStatDataModel getProcStatus() {
return procStatus;
}
public SingleProcess[] getSelectedProcs() {
return selectedProcs;
}
public void setSelectedProcs(SingleProcess[] selectedProcs) {
this.selectedProcs = selectedProcs;
}
public void check(SelectEvent event) {
System.out.println("in check");
}
}

Related

Expanding ADF table row programatically on clicking commandLink

I have a column displaying author name and a command link "Show Documents". I want to expand the row on click of Show Documents command Link as happens on clicking detailStamp facet icon.
Here comes the JSFF code:
<af:table var="row" rowBandingInterval="0" id="rohitT"
value="#{pageFlowScope.parseData.AList}" rowSelection="multiple"
binding="#{pageFlowScope.parseData.dataTable}"
disclosedRowKeys="#{pageFlowScope.parseData.disclosedKeys}">
<af:column sortable="false" headerText="Author" id="c3">
<af:outputText value="#{row.author}" id="ot5"/>
<af:commandLink text="Show Documents" id="sd"
actionListener="#{pageFlowScope.parseData.prepareLOV}" partialSubmit="true" >
</af:commandLink>
<af:outputText value="Disclosed Key::#{pageFlowScope.parseData.disclosedKeys}"
id="ot6"/>
</af:column>
<af:column sortable="false" headerText="Subject area" id="c2">
<af:outputText value="#{row.subjectArea}" id="ot4"/>
</af:column>
<af:column sortable="false" headerText="Select" id="c1">
<af:selectBooleanCheckbox id="sbc1" selected="false" autoSubmit="true"
disabled="#{pageFlowScope.optionSelected ne 'Default' and pageFlowScope.optionSelected ne 'One'}" valueChangeListener="#{pageFlowScope.parseData.onChange}"/>
<af:outputText value="PageFlow::#{pageFlowScope.optionSelected}"
id="ot3"/></af:column>
<f:facet name="detailStamp" >
<af:group id="g1">
<af:selectOneListbox label="Label 1" id="sol1"
value="#{pageFlowScope.parseData.selectedValues}">
<f:selectItems value="#{pageFlowScope.parseData.allValuesList}"
id="si2"/>
</af:selectOneListbox>
</af:group>
</f:facet>
</af:table>
Here comes the managed bean code:
List selectedValues;
private RowKeySetImpl disclosedKeys=null;
List<SelectItem> allValuesList;
public void setDisclosedKeys(RowKeySetImpl disclosedKeys) {
this.disclosedKeys = disclosedKeys;
}
public void setAllValuesList(List<SelectItem> allValuesList) {
this.allValuesList = allValuesList;
}
public List<SelectItem> getAllValuesList() {
if (allValuesList == null) {
allValuesList = new ArrayList<SelectItem>();
allValuesList.add(new SelectItem(1, "India"));
allValuesList.add(new SelectItem(2, "Australia"));
allValuesList.add(new SelectItem(3, "America"));
allValuesList.add(new SelectItem(4, "United Kingdom"));
}
return allValuesList;
}
public void setSelectedValues(List selectedValues) {
this.selectedValues = selectedValues;
}
public List getSelectedValues() {
if (selectedValues == null) {
selectedValues = new ArrayList();
selectedValues.add(1);
selectedValues.add(3);
System.out.println("List is-" + selectedValues);
}
return selectedValues;
}
public void setDisclosedKeys(RowKeySetImpl disclosedKeys) {
this.disclosedKeys = disclosedKeys;
}
public RowKeySetImpl getDisclosedKeys() {
return disclosedKeys;
}
public void prepareLOV(ActionEvent actionEvent) {
disclosedKeys =null;
callDetailStamp();
RowKeySetImpl testDisclosedKey=getDisclosedKeys();
System.out.println("testDisclosedKey before refresh::"+testDisclosedKey);
AdfFacesContext.getCurrentInstance().addPartialTarget(getDataTable());
}
private void callDetailStamp() {
RowKeySet rks = getDataTable().getSelectedRowKeys();
Key currentKey = null;
Object objKey=null;
Iterator rksIter = rks.iterator();
while (rksIter.hasNext())
{
System.out.println("Entered Loop");
objKey=(Object)rksIter.next();
System.out.println("Obj Key::"+objKey);
}
if (rks.size()>0) {
System.out.println("Setting disclosed keys");
disclosedKeys = new RowKeySetImpl();
if (getDataTable() != null) {
ArrayList newKeys = new ArrayList();
ArrayList temp = new ArrayList();
temp.add(0,objKey);
newKeys.add(temp);
disclosedKeys.addAll(newKeys);
}
}
else
{
disclosedKeys = new RowKeySetImpl();
}
System.out.println("Disclosed Key::"+disclosedKeys.toString());
setDisclosedKeys(disclosedKeys);
}
I think I am able to set disclosedRowKeys property as I am able to print its value in output text. Whatever row I select, I get the disclosedKeyValue as an Array of index of the particular selected row. Clicking on link sets disclosedKeys value and refreshes the table but not expanding the row. Am I missing out something here ?

How to fetch checkbox (generated inside a iterator tag) values in Action Class

Background
we have a list of items and each item can be selected by checking its checkbox. If a submit button is clicked after selecting all necessary checkboxes. So now, in our Action class, we could get the values of checkboxes which had been selected, by which we can store the selection check box values in Database.
Environment: Struts 2.3.20
When run the below mentioned code, the JSP creates the dynamic checkboxes perfectly fine. But when I select the checkboxes and hit SAVE button I get the below mentioned error. If Anybody who has encountered similar issue can share their experience on how they resolved this issue would be highly appreciated.
ERROR:
Null pointer exception at Line 54 of Action Class.
( com.testapp.struts2.actions.AddProductsAction.execute(AddProductsAction.java:54)
addProducts.jsp :
<s:form action="addProducts2Campaign" method="post">
<s:iterator value="productsList" status="stat">
<tr bgcolor="<s:if test="#productStatus.odd == true">#999999</s:if><s:else>#CEDDF4</s:else>">
<td align="center">
<s:checkbox name="selectedProductsList[%{#stat.index}]" theme="simple" fieldValue="%{productId}"/>
</td>
<td align="center"><s:property value="Title" /></td>
<td align="center"><s:property value="SKU" /></td>
<td align="center"><s:property value="Description" /></td>
<td align="center"><s:property value="Price" /></td>
</tr>
</s:iterator>
</s:form>
ADDPRODUCTSACTION.java
public class AddProductsAction extends ActionSupport implements ModelDriven<Products>{
private Products products = new Products();
private Map<Integer, Boolean> selectedProducts;
#Override
public Products getModel() {
// TODO Auto-generated method stub
return products;
}
public String execute() throws Exception {
ProductDAO productDAO = new ProductDAO();
ArrayList<Integer> productIds2Add = new ArrayList();
(Line 54:>> below)
for (Entry<Integer, Boolean> entry : selectedProducts.entrySet()) {
Integer key=entry.getKey();
Boolean value=entry.getValue();
if(value == true){
productIds2Add.add(key);
}
}
products.setProductIds2Add(productIds2Add);
productDAO.addProducts(products);
return IConstants.SUCCESS;
}// End of execute()
public Products getProducts() {
return products;
}
public void setProducts(Products products) {
this.products = products;
}
public void setSelectedProducts(Map<Integer, Boolean> selectedProducts) {
this.selectedProducts = selectedProducts;
}
}
PRODUCT.JAVA
public class Products {
private ArrayList<Integer> productIds2Add;
public ArrayList<Integer> getProductIds2Add() {
return productIds2Add;
}
public void setProductIds2Add(ArrayList<Integer> productIds2Add) {
this.productIds2Add = productIds2Add;
}
}
I figured out the cause. struts.xml didn't have the the input property set because of which the Model was not getting set with the values. Once I added that it worked.
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
<constant name="struts.devMode" value="true" />
<constant name="struts.custom.i18n.resources" value="ApplicationResources" />
<constant name="struts.ui.theme" value="simple" />
<package name="default" extends="struts-default">
<action name="addProducts2Campaign" method="execute" class="com.myapp.actions.AddProductsAction">
**<result name="input">/products/addProducts.jsp</result>**
<result name="success">/products/confirmation.jsp</result>
<result name="error">/error.jsp</result>
</action>
</package>
</struts>

How to call a method in controller on picklist change?

<apex:selectList size="1" value="{! LimitSize}">
<apex:selectOptions value="{! paginationSizeOptions}" />
</apex:selectList>
This is my pick list.
private String LimitSize = '';
public String getLimitSize() {
return LimitSize;
}
public void setLimitSize(String LimitSize) {
this.LimitSize = LimitSize;
}
public SelectOption[] paginationSizeOptions {
public get;
private set;
}
public SiteController2(){
String[] paginationSize = new String[]{'2','5','10','200','250' };
this.paginationSizeOptions = new SelectOption[]{};
for (String c: paginationSize) {
this.paginationSizeOptions.add(new SelectOption(c,c));
}
LimitSize = paginationSize[0];
}
public checkLimitSize(){
system.debug('Limit Size : '+LimitSize);
}
Now on change of picklist I want to assign LimitSize variable with selected value of picklist and call method checkLimitSize() to check the value. How can I do that?Thanks.
You can use apex:actionFunction component:
add actionFunction component to page
<apex:actionFunction action="{!yourControllerMethod}" name="yourFunction"/>
Add method to controller
public PageReference yourControllerMethod(){
//body of method
checkLimitSize();
return null;
}
add actionFunction call on
<apex:selectList onchange="yourFunction() ...."
For more information read the documentation.

popupPanel not show in rich:dataTable

Base on the sample from:
http://showcase.richfaces.org/richfaces/component-sample.jsf?demo=dataTable&sample=dataTableEdit&skin=blueSky
I did a bit modify on the xhtml page and CarBean to include a button to display the result. Result display as expected but the popup panel not working (ie. no popup).
Software version I use:
richface 4.3.0 Final
GAE 1.7.2
Note: It work fine on my local notebook and problem mention above apply when deploy online.
Here the online url
http://cloudenterpriseapps.appspot.com/public/test/testPopup5.jsf
Any help?
[CarsBean.java]
package test.faces.bean;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.Iterator;
import java.util.List;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
import javax.faces.bean.ViewScoped;
import javax.faces.event.ValueChangeEvent;
import javax.faces.model.SelectItem;
import org.richfaces.demo.common.data.RandomHelper;
import org.richfaces.demo.tables.model.cars.InventoryItem;
import org.richfaces.demo.tables.model.cars.InventoryVendorItem;
import org.richfaces.demo.tables.model.cars.InventoryVendorList;
#ManagedBean(name = "carsBean2")
#SessionScoped
public class CarsBean2 implements Serializable {
/**
*
*/
private static final long serialVersionUID = -3832235132261771583L;
private static final int DECIMALS = 1;
private static final int CLIENT_ROWS_IN_AJAX_MODE = 15;
private static final int ROUNDING_MODE = BigDecimal.ROUND_HALF_UP;
private List<InventoryItem> allInventoryItems = null;
private List<InventoryVendorList> inventoryVendorLists = null;
private int currentCarIndex;
private InventoryItem editedCar;
private int page = 1;
private int clientRows;
public void switchAjaxLoading(ValueChangeEvent event) {
this.clientRows = (Boolean) event.getNewValue() ? CLIENT_ROWS_IN_AJAX_MODE : 0;
}
public void remove() {
allInventoryItems.remove(allInventoryItems.get(currentCarIndex));
}
public void store() {
allInventoryItems.set(currentCarIndex, editedCar);
}
public List<SelectItem> getVendorOptions() {
List<SelectItem> result = new ArrayList<SelectItem>();
result.add(new SelectItem("", ""));
for (InventoryVendorList vendorList : getInventoryVendorLists()) {
result.add(new SelectItem(vendorList.getVendor()));
}
return result;
}
public List<String> getAllVendors() {
List<String> result = new ArrayList<String>();
for (InventoryVendorList vendorList : getInventoryVendorLists()) {
result.add(vendorList.getVendor());
}
return result;
}
public List<InventoryVendorList> getInventoryVendorLists() {
synchronized (this) {
if (inventoryVendorLists == null) {
inventoryVendorLists = new ArrayList<InventoryVendorList>();
List<InventoryItem> inventoryItems = getAllInventoryItems();
Collections.sort(inventoryItems, new Comparator<InventoryItem>() {
public int compare(InventoryItem o1, InventoryItem o2) {
return o1.getVendor().compareTo(o2.getVendor());
}
});
Iterator<InventoryItem> iterator = inventoryItems.iterator();
InventoryVendorList vendorList = new InventoryVendorList();
vendorList.setVendor(inventoryItems.get(0).getVendor());
while (iterator.hasNext()) {
InventoryItem item = iterator.next();
InventoryVendorItem newItem = new InventoryVendorItem();
itemToVendorItem(item, newItem);
if (!item.getVendor().equals(vendorList.getVendor())) {
inventoryVendorLists.add(vendorList);
vendorList = new InventoryVendorList();
vendorList.setVendor(item.getVendor());
}
vendorList.getVendorItems().add(newItem);
}
inventoryVendorLists.add(vendorList);
}
}
return inventoryVendorLists;
}
private void itemToVendorItem(InventoryItem item, InventoryVendorItem newItem) {
newItem.setActivity(item.getActivity());
newItem.setChangePrice(item.getChangePrice());
newItem.setChangeSearches(item.getChangeSearches());
newItem.setDaysLive(item.getDaysLive());
newItem.setExposure(item.getExposure());
newItem.setInquiries(item.getInquiries());
newItem.setMileage(item.getMileage());
newItem.setMileageMarket(item.getMileageMarket());
newItem.setModel(item.getModel());
newItem.setPrice(item.getPrice());
newItem.setPriceMarket(item.getPriceMarket());
newItem.setPrinted(item.getPrinted());
newItem.setStock(item.getStock());
newItem.setVin(item.getVin());
}
public String queryRec(){
String result = "";
synchronized (this) {
getAllInventoryItems();
}
return result;
}
public String initQuery(){
String result = "";
synchronized (this) {
allInventoryItems = null;
}
return result;
}
public List<InventoryItem> getInventoryItems() {
return allInventoryItems;
}
public List<InventoryItem> getAllInventoryItems() {
synchronized (this) {
if (allInventoryItems == null) {
allInventoryItems = new ArrayList<InventoryItem>();
for (int k = 0; k <= 5; k++) {
try {
switch (k) {
case 0:
allInventoryItems.addAll(createCar("Chevrolet", "Corvette", 5));
allInventoryItems.addAll(createCar("Chevrolet", "Malibu", 8));
allInventoryItems.addAll(createCar("Chevrolet", "Tahoe", 6));
break;
case 1:
allInventoryItems.addAll(createCar("Ford", "Taurus", 12));
allInventoryItems.addAll(createCar("Ford", "Explorer", 11));
break;
case 2:
allInventoryItems.addAll(createCar("Nissan", "Maxima", 9));
allInventoryItems.addAll(createCar("Nissan", "Frontier", 6));
break;
case 3:
allInventoryItems.addAll(createCar("Toyota", "4-Runner", 7));
allInventoryItems.addAll(createCar("Toyota", "Camry", 15));
allInventoryItems.addAll(createCar("Toyota", "Avalon", 13));
break;
case 4:
allInventoryItems.addAll(createCar("GMC", "Sierra", 8));
allInventoryItems.addAll(createCar("GMC", "Yukon", 10));
break;
case 5:
allInventoryItems.addAll(createCar("Infiniti", "G35", 6));
allInventoryItems.addAll(createCar("Infiniti", "EX35", 5));
break;
default:
break;
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
}
return allInventoryItems;
}
public List<InventoryItem> createCar(String vendor, String model, int count) {
ArrayList<InventoryItem> iiList = null;
try {
int arrayCount = count;
InventoryItem[] demoInventoryItemArrays = new InventoryItem[arrayCount];
for (int j = 0; j < demoInventoryItemArrays.length; j++) {
InventoryItem ii = new InventoryItem();
ii.setVendor(vendor);
ii.setModel(model);
ii.setStock(RandomHelper.randomstring(6, 7));
ii.setVin(RandomHelper.randomstring(17, 17));
ii.setMileage(new BigDecimal(RandomHelper.rand(5000, 80000)).setScale(DECIMALS, ROUNDING_MODE));
ii.setMileageMarket(new BigDecimal(RandomHelper.rand(25000, 45000)).setScale(DECIMALS, ROUNDING_MODE));
ii.setPrice(new Integer(RandomHelper.rand(15000, 55000)));
ii.setPriceMarket(new BigDecimal(RandomHelper.rand(15000, 55000)).setScale(DECIMALS, ROUNDING_MODE));
ii.setDaysLive(RandomHelper.rand(1, 90));
ii.setChangeSearches(new BigDecimal(RandomHelper.rand(0, 5)).setScale(DECIMALS, ROUNDING_MODE));
ii.setChangePrice(new BigDecimal(RandomHelper.rand(0, 5)).setScale(DECIMALS, ROUNDING_MODE));
ii.setExposure(new BigDecimal(RandomHelper.rand(0, 5)).setScale(DECIMALS, ROUNDING_MODE));
ii.setActivity(new BigDecimal(RandomHelper.rand(0, 5)).setScale(DECIMALS, ROUNDING_MODE));
ii.setPrinted(new BigDecimal(RandomHelper.rand(0, 5)).setScale(DECIMALS, ROUNDING_MODE));
ii.setInquiries(new BigDecimal(RandomHelper.rand(0, 5)).setScale(DECIMALS, ROUNDING_MODE));
demoInventoryItemArrays[j] = ii;
}
iiList = new ArrayList<InventoryItem>(Arrays.asList(demoInventoryItemArrays));
} catch (Exception e) {
e.printStackTrace();
}
return iiList;
}
public int getCurrentCarIndex() {
return currentCarIndex;
}
public void setCurrentCarIndex(int currentCarIndex) {
this.currentCarIndex = currentCarIndex;
}
public InventoryItem getEditedCar() {
return editedCar;
}
public void setEditedCar(InventoryItem editedCar) {
this.editedCar = editedCar;
}
public int getPage() {
return page;
}
public void setPage(int page) {
this.page = page;
}
public int getClientRows() {
return clientRows;
}
public void setClientRows(int clientRows) {
this.clientRows = clientRows;
}
}
[testPopup5.xhtml]
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:rich="http://richfaces.org/rich"
xmlns:a4j="http://richfaces.org/a4j"
xmlns:c="http://java.sun.com/jsp/jstl/core">
<ui:composition>
<h:head>
<title>RichFaces Showcase</title>
</h:head>
<h:body>
<h:outputStylesheet>
a.no-decor>img {
border: none;
}
</h:outputStylesheet>
<a4j:status onstart="#{rich:component('statPane')}.show()"
onstop="#{rich:component('statPane')}.hide()" />
<h:form>
<h:panelGrid columns="2">
<a4j:commandButton id="search" action="#{carsBean2.queryRec}"
value="Search" render="table" />
<a4j:commandButton id="reset" action="#{carsBean2.initQuery}"
value="Reset" type="reset" render="table" />
</h:panelGrid>
</h:form>
<h:form>
<rich:dataTable value="#{carsBean2.inventoryItems}" var="car"
id="table" rows="5">
<rich:column>
<f:facet name="header">Model</f:facet>
<h:outputText value="#{car.model}" />
</rich:column>
<rich:column>
<f:facet name="header">Price</f:facet>
<h:outputText value="#{car.price}" />
</rich:column>
<rich:column>
<a4j:commandLink styleClass="no-decor" render="editGrid"
execute="#this" oncomplete="#{rich:component('editPanel')}.show()">
<h:graphicImage value="/images/icons/common/edit.gif" alt="edit" />
<f:setPropertyActionListener target="#{carsBean2.editedCar}"
value="#{car}" />
</a4j:commandLink>
</rich:column>
</rich:dataTable>
<rich:popupPanel id="statPane" autosized="true" rendered="true">
<h:graphicImage value="/images/common/ai.gif" alt="ai" />
Please wait...
</rich:popupPanel>
<rich:popupPanel header="Edit Car Details" id="editPanel">
<h:panelGrid columns="3" id="editGrid">
<h:outputText value="Model" />
<h:outputText value="#{carsBean2.editedCar.model}" />
<h:panelGroup />
<h:outputText value="Price" />
<h:outputText value="#{carsBean2.editedCar.price}" />
<h:panelGroup />
</h:panelGrid>
<a4j:commandButton value="Cancel"
onclick="#{rich:component('editPanel')}.hide(); return false;" />
</rich:popupPanel>
</h:form>
</h:body>
</ui:composition>
</html>
Using firebug, I manage discover few diff between local and online GAE version.
1) editPanel # local change it style stage from 'visibility hidden' to 'display none' and then 'display block' when click on edit icon.
However editPanel # GAE still remain unchange with 'visibility hidden'
[Local]
<div id="j_idt9:editPanel" style="visibility: hidden;">
<div id="j_idt9:editPanel" style="display: none;">
<div id="j_idt9:editPanel" style="display: block;">
[GAE]
<div id="j_idt9:editPanel" style="visibility: hidden;">
2) under , local version contain value in table tag
3) Shown in firebug's script tab, when click on edit link, local version display as: and follow by table values.
However online version display it as and without any table values
p/s: Online: http://cloudenterpriseapps.appspot.com/public/test/testPopup5.jsf
By the way the GAE display below warning when page first load. Don't know is related to the problem or not.
[s~cloudenterpriseapps/0.365021621033424561].: SystemId Unknown; Line #57; Column #31; Failed calling setMethod method
[FireBug Script tab, Local. Click on edit link]
<?xml version='1.0' encoding='UTF-8'?>
<partial-response><changes><update id="j_idt9:editGrid"><![CDATA[<table id="j_idt9:editGrid">
<tbody>
<tr>
<td>Model</td>
<td>Corvette</td>
<td></td>
</tr>
<tr>
<td>Price</td>
<td>47405</td>
<td></td>
</tr>
</tbody>
</table>
]]></update><update id="javax.faces.ViewState"><![CDATA[H4sIAAAAAAEUTEh...EUXAkFAAA]]></update></changes><extension id="org.richfaces.extension"><complete>RichFaces.$('j_idt9:editPanel').show();</complete><render>j_idt9:editGrid</render></extension></partial-response>
[FireBug Script tab, GAE. Click on edit link]
<?xml version='1.0' encoding='UTF-8'?>
<partial-response><changes><update id="javax.faces.ViewState"><![CDATA[H4sIAAAAAAAAANVYbW....KBTUkFAAA]]></update></changes></partial-response>
Solved after upgrade JSF api and implementation jar from 2.0 to 2.1

Bean doesnt save state of lists gae

Items of lists should add from one list to another when you press command button. For the first time, it works fine, items move, but for the second time the new ones replace previously added, String fields works fine. When it runs locally it works fine, but uploded to cloude not.
Bean
#ManagedBean
#SessionScoped
public class SmsBean implements Serializable {
private static final long serialVersionUID = 1L;
private List<SelectItem> listOfDevices=new LinkedList<SelectItem>();
private List<SelectItem> listOfSelectedDevices=new LinkedList<SelectItem>();
private List<Device> toAdd=new LinkedList<Device>();
private List<Device> toDelete=new LinkedList<Device>();
public SmsBean(){
List<Entity> entities = Datastore.getTotalDevices();
if(entities!=null){
for(Entity et :entities){
Device device=new Device((String)et.getProperty(DEVICE_DEVICE_NAME_PROPERTY),(String)et.getProperty(DEVICE_MAIL_PROPERTY),(String)et.getProperty(DEVICE_REG_ID_PROPERTY));
listOfDevices.add(new SelectItem(device));
}
}
}
public void addDevices(){
int temp=0;
for(Device dev:toAdd){
for(int j=0;j<listOfDevices.size();j++){
if(((Device)listOfDevices.get(j).getValue()).equals(dev)){
temp=j;
break;
}
}
listOfSelectedDevices.add(listOfDevices.get(temp));
listOfDevices.remove(temp);
}
toAdd.clear();
}
public void deleteDevices(){
int temp=0;
for(Device dev:toDelete){
for(int j=0;j<listOfSelectedDevices.size();j++){
if(((Device)listOfSelectedDevices.get(j).getValue()).equals(dev)){
temp=j;
break;
}
}
listOfDevices.add(listOfSelectedDevices.get(temp));
listOfSelectedDevices.remove(temp);
}
toDelete.clear();
}
}
view
<h:panelGrid columns="4" style="height:100%">
<p:selectManyMenu style="height:230px;width:150px;"
id="selectedDevices" value="#{smsBean.toDelete}"
converter="deviceConverter">
<f:selectItems value="#{smsBean.listOfSelectedDevices}" />
</p:selectManyMenu>
<p:commandButton actionListener="#{smsBean.deleteDevices}"
icon="ui-icon ui-icon-circle-triangle-e" process="#form"
update="devices" title="Icon Only" />
<p:commandButton actionListener="#{smsBean.addDevices}"
process="#form" update="selectedDevices"
icon="ui-icon ui-icon-circle-triangle-w" title="Icon Only" />
<p:selectManyMenu id="devices" value="#{smsBean.toAdd}"
converter="deviceConverter" style="height:230px;width:150px;">
<f:selectItems value="#{smsBean.listOfDevices}" />
</p:selectManyMenu>
</h:panelGrid>

Resources