incubator-adffaces-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "D. Cardon" <my_trash_m...@yahoo.com>
Subject Re: [Trinidad] about usage of SelectManyShuttle/SelectOrderShuttle
Date Mon, 16 Apr 2007 18:09:29 GMT
Renzo,

Sorry again!  I'm giving up on Yahoo! mail--writing
code in it is not very effective.

Here's the final message (I promise):

In order to populate the list of selectable items from
your backing bean, you can use:

<f:selectItems value="#{backingBean.shuttleItems} />

The backingBean object should have a 'getShuttleItems'
accessor, which returns a: SelectItem[].  Each select
item may be an object-label pair, so there's where you
store your object reference.  The value of the shuttle
component is an array of the objects (those which
appear in the object label pairs) that are currently
selected (on the right side of the shuttle).

For example, suppose the component on the page looks
like this:

<tr:selectManyShuttle
value="#{backingBean.selectedShuttleItems}">
	<f:selectItems value="#{backingBean.shuttleItems}" />
</tr:selectManyShuttle>

...and our backing bean looks like this:

(BackingBean.java)
...
//
//  The list of selected items that should appear in
//  the shuttle component.
//
Gizmo [] itemList = null;

//
//  Returns the current selected objects.
//
Gizmo [] getSelectedShuttleItems()
{
	buildItemList();
	//
	//	We'll select the second and fourth items.
	//
	Gizmo[] selectedGizmos = new Gizmo[ 2 ];
	selectedGizmos[ 0 ] = itemList[ 1 ];
	selectedGizmos[ 1 ] = itemList[ 3 ];
	return selectedGizmos;
}

//
//	Retrieves all of the items in the shuttle (not just
the selected ones).
//
public SelectItem[] getShuttleItems()
{
	buildItemList();

	SelectItem[] shuttleItems = new SelectItem[
itemList.length ];
	for ( int index = 0; index < shuttleItems.length;
++index )
	{
		shuttleItems[ index ] = new SelectItem( itemList[
index ], "Label " + index );
	}
}

//
//	Builds the item list, but only if necessary.
//
private void buildItemList()
{
	if ( itemList == null )
	{
		itemList = new Gizmo[ 10 ];
		//
		//	Initialize your gizmos here.
		//
	}
}

--------------------------------

Note that you should implement setters for the
selectedShuttleItems and the shuttleItems, or the
component may render as read-only.  Also, if the
selectedShuttleItems contains an object that is not
listed in the  shuttleItems, you will get some errors.

Good luck and sorry about the incomplete listings
(earlier)--it's my first post.

--David




__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

Mime
View raw message