You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Gregg D Bolinger <gt...@gmail.com> on 2005/05/10 21:58:33 UTC
IPropertySelectionModel
I am having a hard time wrapping my head around the proper way to create a
select list of items. I need to have a value/label so that the value is the
database key and the label is a simple String.
I've looked at the example in the vlib that is in the 4.0 alpha distro. I
understand how the EntitySelectionModel works but I'd just like to know if
this is:
A. The *preferred* way and doing this and
B. does 4.0 provide any more convenience classes similar to
StringSelectionModel that allows for the value/label pair to be used rather
than rolling my own (which isn't that difficult anyway).
Thanks.
Gregg
Re: Simple loop for Select
Posted by Harish Krishnaswamy <ha...@gmail.com>.
How about creating the array in OGNL and simply using the index in the loop ...
<span jwcid="@Foreach" source="new int[100]" index="ognl:idx">
<option jwcid="@Option" label="ognl:idx" />
</span.
-Harish
On 5/10/05, Henry Chen <he...@gmail.com> wrote:
> Hi, I have a question about constructing a simple "SELECT" element.
>
> For example, I need something like this:
>
> <select>
> <option value="1">1</option>
> <option value="2">2</option>
> <option value="3">3</option>
> <option value="4">4</option>
> <option value="5">5</option>
> ...
> <option value="100">100</option>
> </select>
>
> I know @Foreach can do it but I still need to create an array for it. Is it
> possible that I can just loop an int variable and assign its value?
>
> Thanks a lot.
>
> Henry
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
Re: Simple loop for Select
Posted by Paul Ferraro <pm...@columbia.edu>.
The Foreach component also accepts an iterator for its source
parameter. I use a custom Iterator implementation to achieve simple
looping behavior:
<span jwcid="Foreach" source="ognl:new CounterIterator(1, 100)"
...>...</span>
where CounterIterator is defined as:
public class CounterIterator implements Iterator
{
private int index;
private int max;
public CounterIterator(int start, int max)
{
this.index = start;
this.max = max;
}
public boolean hasNext()
{
return index <= max;
}
public Object next()
{
return new Integer(index++);
}
public void remove()
{
throw new UnsupportedOperationException();
}
};
Henry Chen wrote:
>Hi, I have a question about constructing a simple "SELECT" element.
>
>For example, I need something like this:
>
><select>
> <option value="1">1</option>
> <option value="2">2</option>
> <option value="3">3</option>
> <option value="4">4</option>
> <option value="5">5</option>
> ...
> <option value="100">100</option>
></select>
>
>I know @Foreach can do it but I still need to create an array for it. Is it
>possible that I can just loop an int variable and assign its value?
>
>Thanks a lot.
>
>Henry
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
Simple loop for Select
Posted by Henry Chen <he...@gmail.com>.
Hi, I have a question about constructing a simple "SELECT" element.
For example, I need something like this:
<select>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
...
<option value="100">100</option>
</select>
I know @Foreach can do it but I still need to create an array for it. Is it
possible that I can just loop an int variable and assign its value?
Thanks a lot.
Henry
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org