You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Leon Derks <le...@cumquat.nl> on 2008/05/08 15:38:34 UTC
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: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: overwrite first element in select
Posted by Adam Zimowski <zi...@gmail.com>.
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();
WebDaoParameter<Integer> param = new WebDaoParameter<Integer>();
param.setMode(PagingMode.NoPaging);
param.setSchemed(schema);
final List<NodeBean> 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 List<OptionGroupModel> getOptionGroups() {
return __model.getOptionGroups();
}
public List<OptionModel> 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 <le...@cumquat.nl> 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: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
RE: overwrite first element in select
Posted by "Blower, Andy" <An...@proquest.co.uk>.
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:leon.derks@cumquat.nl]
> 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: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org