File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Other Application Frameworks and the fly likes 'select' componet in tapestry Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Other Application Frameworks
Bookmark " Watch " New topic
Author

'select' componet in tapestry

David George
Greenhorn

Joined: Aug 23, 2005
Posts: 10
I don't know why i can not get the submitted value of the dropdown list , it always be null .The code is below :
html:
<td>
<select jwcid="places"></select>
</td>
page:
<property name="place"/>

<component id="places" type="PropertySelection">
<binding name="value" value="place"/>
<binding name="model" value="placeDropdownList"/>
</component>
java:
public abstract class TestTapestry extends BasePage
{

public abstract void setPlace(String place);

public abstract String getPlace();

public List getList()
{
List<List<String>> list = new ArrayList<List<String>>();
List<String> list1 = new ArrayList<String>();
List<String> list2 = new ArrayList<String>();
list1.add("Beijing");
list1.add("Shanghai");
list1.add("Xianggang");
list1.add("Dongjing");
list2.add("北京");
list2.add("上海");
list2.add("香港");
list2.add("东京");

list.add(list1);
list.add(list2);

return list;
}

public IPropertySelectionModel getPlaceDropdownList()
{
PlaceDropdownList places = new PlaceDropdownList();
places.placesList = this.getList();
setPlace("Dongjing");
return places;
}

public String submit(IRequestCycle cycle)
{
System.out.println(getPlace());
}


private class PlaceDropdownList implements IPropertySelectionModel
{
List placesList = null;

public String getLabel(int arg0) {
List list = (List)placesList.get(1);
return (String)list.get(arg0);
}

public Object getOption(int arg0) {
List list = (List)placesList.get(0);
return list.get(arg0);
}

public String getValue(int arg0) {
List list = (List)placesList.get(0);
return (String)list.get(arg0);
}

public int getOptionCount() {
return ((List)placesList.get(0)).size();
}

public Object translateValue(String arg0) {
return arg0;
}
}
}

when submit method invoked , will get null . Waiting for your help , thank you very much.
[ August 15, 2006: Message edited by: David George ]
Anselm Paulinus
Ranch Hand

Joined: Sep 05, 2003
Posts: 389
getPlace() should be null; I am damn sure getPlaceDropdownList()
was never called; if you want getPlace() to have value; try setting setPlace() in pageBeginRender() method; remember this method is called only if your class implements PageBeginRenderListener interface.
 
 
subject: 'select' componet in tapestry
 
Similar Threads
Need help in List
Generics Generics Generics !!!
Using Two ArrayLists For One Table
Accessing elements from an arraylist
Collection