tapestry-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Ameet Shah" <as...@tirawireless.com>
Subject MultiplePropertySelection HELP?!
Date Mon, 11 Aug 2003 17:19:37 GMT
Hello,

I am trying to use the multiple property selection component in the Tapestry contrib library.
 I have been able to set it up so that it displays the specified output correctly, but for
some reason, when I submit the form, it the list is empty despite the fact that I have more
than one option selected.  It appears that it is actually removing everything from the list,
and then not re-adding the ones that are selected.  Has anyone else had a similar problem?
 Its probably a config issue on my part.  

Any help would be GREATLY appreciated.  Thanks!

Here is the relevant code:

AddCapability.page
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE page-specification PUBLIC
 "-//Apache Software Foundation//Tapestry Specification 3.0//EN"
 "http://jakarta.apache.org/tapestry/dtd/Tapestry_3_0.dtd">
 
<page-specification class="com.tira.tapestry.devicecaps.pages.AddCapabilityPage">

	<!-- capability description text field -->
	<component id="description" type="TextField">
		<binding name="value" expression="desc"/>
	</component>

	<!-- capability classification select box -->
	<component id="classificationBox" type="PropertySelection">
		<binding name="model" expression="cb.classificationSelectionModel"/>
		<binding name="value" expression="classification"/>
		<binding name="submitOnChange" expression="false"/>
	</component>
	
	<component id="selectedDevicesBox" type="contrib:MultiplePropertySelection">
		<binding name="model" expression="devicePropertySelection"/>
		<binding name="selectedList" expression="selectedDevices"/>		
	</component>
</page-specification>

AddCapability.java
/*
 * Created on Aug 7, 2003
 *
 */
package com.tira.tapestry.devicecaps.pages;

import org.apache.tapestry.html.BasePage;
import org.apache.tapestry.IRequestCycle;
import com.tira.tapestry.devicecaps.models.DevicePropertySelectionModel;
import com.tira.tapestry.devicecaps.beans.ClassificationListingBean;
import com.tira.tapestry.devicecaps.beans.DeviceListingBean;
import java.util.List;

/**
 * @author ashah
 *
 */
public class AddCapabilityPage extends BasePage {

    // component values
    private String desc;
    private String classification;
    private List selectedDevices;
    private DevicePropertySelectionModel devicePropertySelection;

    // beans
    private ClassificationListingBean cb;
    private DeviceListingBean db;
    
    public AddCapabilityPage() {
        cb = new ClassificationListingBean();
        db = new DeviceListingBean();
        // by default, we select all devices
        selectedDevices = db.getDeviceList();
        devicePropertySelection = new DevicePropertySelectionModel(selectedDevices);
    }
    
    public ClassificationListingBean getCb() {
        return cb;
    }
    
    public void setCb(ClassificationListingBean value) {
        cb = value;
    }
    
    public DeviceListingBean getDb() {
        return db;
    }
    
    public void setDb(DeviceListingBean value) {
        db = value;
    }
    
    public void attachSubmitAction(IRequestCycle cycle) {
        
    }

	/**
	 * @return
	 */
	public String getDesc() {
		return desc;
	}

	/**
	 * @param string
	 */
	public void setDesc(String string) {
		desc = string;
	}

	/**
	 * @return
	 */
	public String getClassification() {
		return classification;
	}

	/**
	 * @param string
	 */
	public void setClassification(String string) {
		classification = string;
	}

	/**
	 * @return
	 */
	public List getSelectedDevices() {
		return selectedDevices;
	}

	/**
	 * @param list
	 */
	public void setSelectedDevices(List list) {
		selectedDevices = list;
	}

	/**
	 * @return
	 */
	public DevicePropertySelectionModel getDevicePropertySelection() {
		return devicePropertySelection;
	}

	/**
	 * @param model
	 */
	public void setDevicePropertySelection(DevicePropertySelectionModel model) {
		devicePropertySelection = model;
	}
}

DevicePropertySelectionModel.java

/*
 * Created on Jul 29, 2003
 *
 */
package com.tira.tapestry.devicecaps.models;

import java.io.Serializable;

import org.apache.tapestry.form.IPropertySelectionModel;
import java.util.List;

/**
 * @author ashah
 * 
 *  Note that this class is used for both PropertySelections and Select's since it
 *  is essentially using the same data, just formatting it differently.
 */
public class DevicePropertySelectionModel
	implements IPropertySelectionModel, Serializable {

    private List deviceList;
        
    public DevicePropertySelectionModel(List deviceList) {
        this.deviceList = deviceList;
    }

	/* (non-Javadoc)
	 * @see org.apache.tapestry.form.IPropertySelectionModel#getOptionCount()
	 */
	public int getOptionCount() {
		return deviceList.size();
	}

	/* (non-Javadoc)
	 * @see org.apache.tapestry.form.IPropertySelectionModel#getOption(int)
	 */
	public Object getOption(int index) {
		return deviceList.get(index);
	}

	/* (non-Javadoc)
	 * @see org.apache.tapestry.form.IPropertySelectionModel#getLabel(int)
	 */
	public String getLabel(int index) {
		return (String)deviceList.get(index);
	}

	/* (non-Javadoc)
	 * @see org.apache.tapestry.form.IPropertySelectionModel#getValue(int)
	 */
	public String getValue(int index) {
        // return index+1 so that we don't have values starting from 0                
		return String.valueOf(index+1);
	}

	/* (non-Javadoc)
	 * @see org.apache.tapestry.form.IPropertySelectionModel#translateValue(java.lang.String)
	 */
	public Object translateValue(String value) {
		// TODO Given the device model name, find the rest of the information about the device.
        return getOption(Integer.parseInt(value));
	}

}



Ameet Shah

Mime
View raw message