This content has been marked as final.
Show 6 replies
-
1. Re: listShuttle : can not get targetValue when submit
ilya_shaikovsky Dec 20, 2007 8:37 AM (in response to xuantoan2510)my page
<h:form> <rich:listShuttle sourceValue="#{capitalsBean.capitals}" targetValue="#{capitalsBean.capitals2}" var="cap" converter="converter"> <rich:column> <h:outputText value="#{cap.name}"/> </rich:column> </rich:listShuttle> <rich:dataTable value="#{capitalsBean.capitals2}" var="list" id="table"> <rich:column> <h:outputText value="#{list.name}"/> </rich:column> </rich:dataTable> <h:commandButton value="store"/> </h:form>
capitalsBean:private List<Capital> capitals2 = new ArrayList<Capital>(); private ArrayList<Capital> capitals = new ArrayList<Capital>(); ... ///initialization // getters , setters
Capital:package demo.table; import java.io.Serializable; public class Capital implements Serializable { /** * */ private String name; private String state; public Capital() { } public Capital(String name, String state) { setName(name); setState(state); } public String getName() { System.out.println(name); return name; } public void setName(String name) { this.name = name; } public String getState() { return state; } public void setState(String state) { this.state = state; } @Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + ((name == null) ? 0 : name.hashCode()); result = prime * result + ((state == null) ? 0 : state.hashCode()); return result; } @Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; final Capital other = (Capital) obj; if (name == null) { if (other.name != null) return false; } else if (!name.equals(other.name)) return false; if (state == null) { if (other.state != null) return false; } else if (!state.equals(other.state)) return false; return true; } }
And the converterpackage demo.table; import javax.faces.component.UIComponent; import javax.faces.context.FacesContext; public class Converter implements javax.faces.convert.Converter{ public Converter() { } public Object getAsObject(FacesContext context, UIComponent component, String value) { int index = value.indexOf(':'); return new Capital(value.substring(0, index), value.substring(index + 1)); } public String getAsString(FacesContext context, UIComponent component, Object value) { Capital optionItem = (Capital) value; return optionItem.getName() + ":" + optionItem.getState(); } }
so, in this simple example - I duplicate values from target lsit to dataTable.
Also check demosite examlpe from SVN to look through the example more closer. -
2. Re: listShuttle : can not get targetValue when submit
xuantoan2510 Dec 20, 2007 10:15 AM (in response to xuantoan2510)Thanks for your reply. I tried your code but I still dont get targetValue when click Store buttom. And your table is not updated.
this is my jsp<%@ page language="java" contentType="text/html;charset=UTF-8" pageEncoding="UTF-8"%> <%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%> <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%> <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> <%@ taglib uri="http://java.sun.com/jstl/fmt" prefix="fmt"%> <%@ taglib uri="http://richfaces.org/a4j" prefix="a4j"%> <%@ taglib uri="http://richfaces.org/rich" prefix="rich"%> <%@ taglib uri="http://myfaces.apache.org/tomahawk" prefix="t"%> <f:view> <ui:composition xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core" xmlns:a4j="http://richfaces.org/a4j" xmlns:rich="http://richfaces.org/rich" xmlns:c="http://java.sun.com/jstl/core"> <h:form> <rich:listShuttle sourceValue="#{capitalsBean.capitals}" targetValue="#{capitalsBean.capitals2}" var="cap" converter="converter"> <rich:column> <h:outputText value="#{cap.name}"/> </rich:column> </rich:listShuttle> <rich:dataTable value="#{capitalsBean.capitals2}" var="list" id="table"> <rich:column> <h:outputText value="#{list.name}"/> </rich:column> </rich:dataTable> <h:commandButton value="store" action="#{capitalsBean.actionSave}" /> </h:form> </ui:composition> </f:view>
i want to get targetValue in actionSave method. Do you suggest? -
3. Re: listShuttle : can not get targetValue when submit
xuantoan2510 Dec 20, 2007 8:12 PM (in response to xuantoan2510)I test successfully with sample and i think that two methods equals and hashCode of property are very important. Thanks
-
4. Re: listShuttle : can not get targetValue when submit
ilya_shaikovsky Dec 22, 2007 7:32 AM (in response to xuantoan2510)sorry.. Forgot to mention that.. I'll check if this point markerd properly in our docs and demo.
-
5. listShuttle : can not get targetValue when submit
ivanjsm Jan 17, 2011 8:34 AM (in response to ilya_shaikovsky)So, what's the results? It seems I'm having the same problem...
-
6. listShuttle : can not get targetValue when submit
ilya_shaikovsky Jan 17, 2011 4:11 PM (in response to ivanjsm)as told there http://community.jboss.org/message/581230#581230 think you have the same problem.