Re: overwrite first element in select

2008-05-08 Thread Adam Zimowski
You can do this when you create select model. For example, in my
application I have a drop down of catagories fetched by a DAO, with
first element being -- Please Select:

@Cached
public SelectModel getCategoriesModel() {

Schemed schema = _catalog.computeOdsSchema();
WebDaoParameterInteger param = new WebDaoParameterInteger();
param.setMode(PagingMode.NoPaging);
param.setSchemed(schema);
final ListNodeBean categories = 
_promosDao.getCategories(param).get();

return new SelectModel() {

private final SelectModel __model;

{
int modelSize = categories.size() + 1;
OptionModel[] options = new 
OptionModel[modelSize];
String blankLabel = -- Please Select;
options[0] = new OptionModelImpl(blankLabel, 0);

int index = 1;
for (NodeBean category : categories) {
String label = 
category.getDescription();
int value = category.getId();
options[index++] = new 
OptionModelImpl(label, value);
}

__model = new SelectModelImpl(options);
}

public ListOptionGroupModel getOptionGroups() {
return __model.getOptionGroups();
}

public ListOptionModel getOptions() {
return __model.getOptions();
}

public void visit(SelectModelVisitor aVisitor) {
__model.visit(aVisitor);
}

};
}

Then, in your TML reference this model as attribute value of your
select component.

On Thu, May 8, 2008 at 8:38 AM, Leon Derks [EMAIL PROTECTED] wrote:
 Hello

 Is it possible to overwrite the first element in a select box?
 At the moment this is an empty value, but can I for example overwrite this
 with All

 Leon

 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: overwrite first element in select

2008-05-08 Thread Blower, Andy
Look at the blankLabel and blankOption attributes for the select component. 
(http://tapestry.apache.org/tapestry5/tapestry-core/ref/org/apache/tapestry/corelib/components/Select.html)

There are good examples in the Tapestry 5 jumpstart. 
(http://files.doublenegative.com.au/jumpstart/)


 -Original Message-
 From: Leon Derks [mailto:[EMAIL PROTECTED]
 Sent: 08 May 2008 14:39
 To: Tapestry users
 Subject: overwrite first element in select

 Hello

 Is it possible to overwrite the first element in a select box?
 At the moment this is an empty value, but can I for example overwrite
 this with All

 Leon

 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]