You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Gary Larsen <ga...@envisn.com> on 2007/03/06 23:46:10 UTC

get selectionList for widget?

I'm trying to get the selection list for a widget from within an
ActionListener.  The goal is to select all/none for a MultiValueField (or
Field for that matter) widget.

 

>From the listener I can use setValues() on the widget, but the possible
values need to be hard-coded.  I would like to set the values using the
selection list of possible values.

 

Is this possible somehow?  It does not seem obvious from the API.

 

Thanks,

gary


RE: get selectionList for widget?

Posted by Gary Larsen <ga...@envisn.com>.
Hi Manuel,

Thanks for your suggestions to my problem.  It got me thinking more about
how to do this from java and finally found the solution.  I'm sure the java
could be compacted a bit but it works! 


AbstractDatatypeWidgetDefinition widgetDef =
(AbstractDatatypeWidgetDefinition) myWidget.getDefinition();
StaticSelectionList selList = (StaticSelectionList)
widgetDef.getSelectionList();
List selListItems = selList.getItems();

for (int i=0; i < selListItems.size(); i++) {
    StaticSelectionList.SelectionListItem selListItem =
(StaticSelectionList.SelectionListItem) selListItems.get(i);
    MyClass value = (MyClass) selListItem.getValue();
}

gary


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


RE: get selectionList for widget?

Posted by Manuel Mata <ma...@yahoo.es>.
I did it using flowscript. I have not the code here
but it is something like.

var w = event.source.parent.lookupWidget("theWidget");
var items = [];
var items[0] = { value : "1", label : "One"};
var items[1] = { value : "2", label : "Two"};
...
w.setSelectionList(items,"value","label");

With this you can set all the items of the selection
list. To set the values (i mean, to show some values
selected in a checkbox styling), you could do
something like:

var values = {1,2};//Array initializing
w.setValues(values);

With this you should get the item with those values
checked.

To recover the selection list use:

var sl = w.getSelectionList();

I think the SelectionList object should have some
methods to get the values, or even it should return
some kind of value/label pair object and recover it
from that object.

I hope this helps.

--- Gary Larsen <ga...@envisn.com> escribió:

> I'm trying to get the selection list for a widget
> from within an
> ActionListener.  The goal is to select all/none for
> a MultiValueField (or
> Field for that matter) widget.
> 
>  
> 
> From the listener I can use setValues() on the
> widget, but the possible
> values need to be hard-coded.  I would like to set
> the values using the
> selection list of possible values.
> 
>  
> 
> Is this possible somehow?  It does not seem obvious
> from the API.
> 
>  
> 
> Thanks,
> 
> gary
> 
> 



		
______________________________________________ 
LLama Gratis a cualquier PC del Mundo. 
Llamadas a fijos y móviles desde 1 céntimo por minuto. 
http://es.voice.yahoo.com

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org