i have the suggestion box with columns when i click or select the the rows in suggestion box the data which i'm selecting one value should remain in same text box and another value should be displayed in another text box.. any suggestion would be great helpful..
here is the code..
index.xhtml
<h:panelGrid columns="2" columnClasses="sb_test_column1,sb_test_column2" width="100%">
<h:outputLabel value="RegNo"/><h:inputText id="regno" value="#{CustomerBean.regno}" />
<h:outputLabel value="Name"/><h:inputText id="name" onclick="openSuggestionBox('SuggestionBoxId','assignmentForm','name','');"/>
</h:panelGrid>
<rich:suggestionbox suggestionAction="#{SelectionBean.autocomplete}" var="cap"
fetchValue="#{cap.name}" for="name" tokens="," width="200" height="150" nothingLabel="No Records found"
id="SuggestionBoxId" >
<h:column>
<h:outputText value="#{cap.regno}"/>
</h:column>
<f:setPropertyActionListener target="#{CustomerBean.sample}" value="regno"/>
<h:column>
<h:outputText value="#{cap.name}" />
</h:column>
</rich:suggestionbox>
java code..
public class SelectionBean{
String suggest = "";
public List<CustomerBean> list = new ArrayList<CustomerBean>();
ResultSet rs;
public SelectionBean()
{
try {
DataBaseHelper db = new DataBaseHelper();
rs=db.select();
while(rs.next())
{
String cod = rs.getString("code");
String nam = rs.getString("name");
CustomerBean cb = new CustomerBean();
cb.setRegno(cod);
cb.setName(nam);
list.add(cb);
}
} catch (SQLException e) {
e.printStackTrace();
}
}
public List<CustomerBean> autocomplete(Object name)
{
String pref = (String) name;
ArrayList<CustomerBean> result = new ArrayList<CustomerBean>();
Iterator<CustomerBean> iterator = list.iterator();
while (iterator.hasNext()) {
CustomerBean elem = ((CustomerBean) iterator.next());
if ((elem.getName()!= null && elem.getName().toLowerCase().indexOf(pref.toLowerCase()) == 0)|| "".equals(pref))
{
result.add(elem);
}
}
return result;
}
}