error in getting elements from "targetValue" in listShuttle
ringfinger Jan 7, 2008 1:34 PMmy list asociated to "listShuttle" no set the elements selected in the page.
using List List instead List (deleting converter="converter.AuctionType"),
the component works fine.
what is the problem? the converter is wrong?
-----------
<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">
<a4j:keepAlive beanName="programBean" ajaxOnly="false"/>
<a4j:form>
<rich:toolBar id="toolBar" itemSeparator="line" height="28px">
<c:forEach items="#{programBean.auctionTypesSld}" var="item">
<h:panelGroup>
<h:outputLink value="#">
<h:outputText value="#{item.acutionName}"></h:outputText>
</h:outputLink>
</h:panelGroup>
</c:forEach>
</rich:toolBar>
<rich:spacer height="20"></rich:spacer>
<rich:listShuttle id="elemShuttle" var="auctType" converter="converter.AuctionType"
sourceValue="#{programBean.auctionTypes}" sourceCaptionLabel="Existentes"
targetValue="#{programBean.auctionTypesSld}" targetCaptionLabel="Autorizadas"
orderControlsVisible="false" fastOrderControlsVisible="false">
<rich:column>
<h:outputText value="#{auctType.acutionName}"></h:outputText>
</rich:column>
<a4j:support id="supportID" event="onlistchanged" immediate="true" reRender="toolBar" actionListener="#{programBean.updateTipoSubastasSld}"/>
</rich:listShuttle>
</a4j:form>
</ui:composition>
--------
public class ProgramBean implements java.io.Serializable {
private List auctionTypes;
private List auctionTypesSld;
.
.
.
public void setAuctionTypes(List auctionTypes) {
this.auctionTypes = auctionTypes;
}
public List getAuctionTypes() {
auctionTypes = getAuctionManager().loadAllAuctionTypes();
return auctionTypes;
}
-------faces-config.xml
<converter-id>converter.AuctionType</converter-id>
<converter-class>com.bns.subastas.custom.converter.AuctionTypeConverter</converter-class>
--------
package com.bns.subastas.custom.converter;
import com.bns.auction.model.auctionTypes.AuctionType;
import java.io.Serializable;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.convert.Converter;
import javax.faces.convert.ConverterException;
import org.apache.commons.lang.StringUtils;
public class AuctionTypeConverter implements Converter {
public AuctionTypeConverter() {
}
private boolean isObjectConvertible(Object value) {
return (value instanceof AuctionType);
}
public Object getAsObject(
FacesContext context,
UIComponent component,
String value)
throws ConverterException {
AuctionType aucType = new AuctionType();
System.out.println("AuctionTypeConverter.getAsObject() value-- >"+value);
if (!StringUtils.isEmpty(value)) {
String[] splitArray = value.split(":");
System.out.println("splitArray:"+splitArray);
aucType.setId(Long.valueOf(splitArray[0]));
aucType.setAcutionName(splitArray[1]);
}
//else{throw new ConverterException(message);
//}
return aucType;
}
public String getAsString(
FacesContext context,
UIComponent component,
Object value)
throws ConverterException {
String valueStr = null;
if (isObjectConvertible(value)) {
System.out.println("isObjectConvertible");
AuctionType aucType = (AuctionType) value;
valueStr = aucType.getId() + ":" + aucType.getAcutionName();
}
return valueStr;
}
}