• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Rich Faces suggestion box

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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%">
<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;

}


}

 
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic