Dynamic Data Load with Rich Faces ComboBox

Rich Faces ComboBox provides editable combobox with a wide set of added functionalities. If there are too many items in the List, there will be huge amount of data downloaded to the client, together with more heavy ComboBoxes on the page and thus the page can be too big or unusable. A solution would be triggering data download by using the ComboBox. Post  describes the implementation of Rich Faces ComboBox without the need of downloading ComboBox content before it is actually needed (onlistcall event driven) and/or to set up the ComboBox value just through Converter.

The main goals of this implementation are:

  1. if the combo isn’t used then the items are not loaded in backing bean or into the client
  2. possibility to set itemValue manually, without itemList load through Converter
  3. itemList is loaded only after onlistcall event.

JSP:

<h:panelGroup id="pG">
	<h:outputLabel id="oLrcmb" for="rcmb" value="Items:" />
	<rich:comboBox id="rcmb" value="#{Bean.itemValue}" defaultLabel="..write the value"
		converter="ItemConverter" suggestionValues="#{Bean.itemList}">
		oncomplete="#{rich:component('rcmb')}.showList();"
		<a4j:support actionListener="#{Bean.fillItemList}" event="onlistcall" reRender="rcmb"
			onsubmit="#{rich:component('rcmb')}.applyDefaultText();"
			limitToList="true" immediate="true" bypassUpdates="false"
			ajaxSingle="true" rendered="#{!Bean.itemListFilled}" />
		<a4j:support event="onblur" ignoreDupResponses="true" ajaxSingle="true"
			limitToList="true" reRender="rcmb" />
	</rich:comboBox>
</h:panelGroup>

Backing Bean:

// list of items
protected List<Item> itemList;

// getter for list of items
public List<Item> getItemList()
{
	return itemList;
}

// action listener method, fullfills itemList on backbean with items
public void fillItemList(ActionEvent e)
{
	itemList=.. // fullfill item list;
}

// checks, if the list of items is fullfilled
public boolean isItemListFilled()
{
	return (itemList != null && itemList.size() > 0);
}

Requirement Engineering, Business Analysis, Agile, Analysis and Design with UML, Java/J2EE, Liferay, Javascript, Embedded C++, MDD, Executable UML, Project Management


© 2017 JULIUSURBAN.NET