• Post Reply Bookmark Topic Watch Topic
  • New Topic

Rich Faces suggestion box  RSS feed

 
karthick arumugam
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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%">
<hutputLabel value="RegNo"/><h:inputText id="regno" value="#{CustomerBean.regno}" />
<hutputLabel 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>
<hutputText value="#{cap.regno}"/>
</h:column>
<f:setPropertyActionListener target="#{CustomerBean.sample}" value="regno"/>

<h:column>
<hutputText 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;

}


}

 
Vaibhav Mittal
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
refer to the rich input suggestion box on this link http://livedemo.exadel.com/richfaces-demo/index.jsp. This should solve your problem. Just a little different from what you want.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!