Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6236677
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T10:53:24+00:00 2026-05-24T10:53:24+00:00

I am trying to use Richfaces suggestion box. Based on the value selected from

  • 0

I am trying to use Richfaces suggestion box. Based on the value selected from the suggestionbox, I am trying to change outputtext value next to it.

Here is my xhtml code:

<td align="left">
    <h:inputText onchange="submit();" immediate="true" id="productname" valueChangeListener="#{salesBean.updateProductRate}" autocomplete="false"/>
</td>
<td align="left">
    <h:outputText id="rate" binding="#{salesBean.productRate}"/>
</td>

<rich:suggestionbox width="290" suggestionAction="#{salesBean.suggest}" var="state" for="productname">      
    <f:facet name="nothingLabel">
        <h:outputText value="No Products found" />
    </f:facet>    
    <f:facet name="header">
        <h:outputText value="Select Product" />
    </f:facet>
    <h:column>
        <h:outputText value="#{state.name}"/>
    </h:column>
</rich:suggestionbox>

When I type ‘a’ in the inputtext (for example) Richfaces suggestionbox shows the list of names starting with letter ‘a’. If I select one of the names (say ‘asd’), only ‘a’ which I typed earlier gets submitted in the form.

How to make the whole name ‘asd’ to get submitted in the form? Please help

Thanks in advance

(I am using JSF 1.2 along with Richfaces 3.3.2)

Updated Code

<td align="left">
                                <h:inputText immediate="true" id="productname" autocomplete="false">

                                </h:inputText>

                            </td>
                            <td align="left">
                                <h:outputText id="rate" binding="#{salesBean.productRate}"/>
                            </td>

<rich:suggestionbox width="290"
suggestionAction="#{salesBean.suggest}" var="state" for="productname">

<f:facet name="nothingLabel">
            <h:outputText value="No Products found" />
            </f:facet>

            <f:facet name="header">
            <h:outputText value="Select Product" />
            </f:facet>
<h:column>
   <h:outputText value="#{state.name}"/>
</h:column>
<a4j:support event="onselect" action="#{salesBean.updateProductRate}" reRender="rate">
             <f:setPropertyActionListener value="#{state.name}" target="#{salesBean.selectedProductName}" />
</a4j:support>

This is my java code

HtmlOutputText productRate = new HtmlOutputText();

public String updateProductRate()
    {
    System.out.println("Successfully entered ");
    SalesDAO dao = new SalesDAO();


    //getProductRate().setValue(dao.fetchRateForProductEntered(evt.getNewValue().toString()));

    //selectedProductName = dao.fetchRateForProductEntered(evt.getNewValue().toString());

    return "success";
}

public HtmlOutputText getProductRate() {
    return productRate;
}


public void setProductRate(HtmlOutputText productRate) {
    this.productRate = productRate;
}

public List<ProductSuggestOBJ> suggest(Object input)
{
    SalesDAO dao = new SalesDAO();
    List<ProductSuggestOBJ> suggestionList = new ArrayList<ProductSuggestOBJ>();

    String userInput = (String)input;

    if(!userInput.trim().equalsIgnoreCase(""))
    {
        suggestionList = dao.suggestProductFromDatabase(userInput);
    }

    return suggestionList;
}

private String selectedProductName;




public String getSelectedProductName() {
    return selectedProductName;
}


public void setSelectedProductName(String selectedProductName) {
    this.selectedProductName = selectedProductName;
}

The same error remains. Plz help.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T10:53:25+00:00Added an answer on May 24, 2026 at 10:53 am

    It seems that you want to select a product from the suggestion box and then call the #{salesBean.updateProductRate} to calculate the product rate for the selected product.

    You can do it by directly attaching an onselect event to the suggestion box using a4j:support instead of using the valueChangeListener of the h:inputText that the suggestion box provides value to.

    <h:inputText  immediate="true" id="productname" />
     <br/>
     <h:outputText id="rate" value="#{salesBean.productRate}"/>
    <rich:suggestionbox width="290" suggestionAction="#{salesBean.suggest}" var="state" for="productname">      
        <f:facet name="nothingLabel">
            <h:outputText value="No Products found" />
        </f:facet>    
        <f:facet name="header">
            <h:outputText value="Select Product" />
        </f:facet>
        <h:column>
            <h:outputText value="#{state.name}"/>
        </h:column>
        <a4j:support event="onselect" action="#{salesBean.updateProductRate}" reRender="rate">
                     <f:setPropertyActionListener value="#{state.name}" target "#{salesBean.selectedProductName}" />
        </a4j:support>
    </rich:suggestionbox>
    

    In the salesBean , add the selectedProductName properties and its getter and setter. In the updateProductRate() , you use the selectedProductName to calculate the product rate and assign the result to the productRate

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to use some xml name spaces here, <html xmlns=http://www.w3.org/1999/xhtml xmlns:h=http://java.sun.com/jsf/html xmlns:a4j=http://richfaces.org/a4j xmlns:rich=http://richfaces.org/rich
I'm trying use rich:suggestionbox . I went through the tutorial provided by the Richfaces.
I'm trying use mod_rewrite to rewrite URLs from the following: http://www.site.com/one-two-file.php to http://www.site.com/one/two/file.php The
I'm trying to use RichFaces on a working JSF2 application. I incorporated the RichFaces
I'm trying to use RichFaces <rich:fileUpload> component (with Seam as the overall framework) to
Trying to migrate a Richfaces 3.3 project to 4. Got to a rich:suggestionBox component
I am trying use std::copy to copy from two different iterator. But during course
I'm trying use to selenium with firefox on CentOS from command line like this:
i'm trying use webview to load a image from sdcard i use this path
I'm trying use regular expression to convert special characters in an url. Here's my

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.