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

  • Home
  • SEARCH
  • 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 7958977
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T04:30:08+00:00 2026-06-04T04:30:08+00:00

Hello i have the following problem. I have a search page lets call it

  • 0

Hello i have the following problem.

I have a search page lets call it search.xhtml and you can search for a bar-code. This value is unique so the result is always one or zero objects from the database

<p:panelGrid columns="1" style="margin:20px;">
  <h:form>
    <p:messages id="messages" globalOnly="true" showDetail="false" />
    <p:message for="barcode" />

    <p:inputText id="barcode" value="#{searchForm.barCode}"
                 required="true" requiredMessage="Value needed" />

    <p:commandButton value="search"
                     action="#{searchForm.searchBarcode}" id="search"/>

  </h:form>
</p:panelGrid>

This is the backingbean:

@ManagedBean
@ViewScoped
public class SearchForm extends BasePage {
  private Long barCode;

  @ManagedProperty("#{daoManager}")
  public DaoManager daoManager;

  public void setDaoManager(DaoManager daoManager) {
    this.daoManager = daoManager;
  }
  public Long getBarCode() {
    return barCode;
  }
  public void setBarCode(Long barCode) {
    this.barCode = barCode;
  }
  public String searchBarcode() {
    //request to dao to get the object
    DataList<Data> data = daoManager.findbybarcode(barCode);
    if (data.size() == 0) {
      this.addMessage(FacesMessage.SEVERITY_ERROR,
                      "Not Found: " + barCode);
      return null;
    } else {       
      getFacesContext().getExternalContext().
        getRequestMap().put("id", data.getId());
      return "details";
    }
  }

So if i go to my details page which expect the parameter id this isnt send to the detail page.

backing bean details page:

@ManagedBean
@ViewScoped
public class DetailBean extends BasePage implements Serializable {
  @PostConstruct
  public void init() {
    if (id != null) {
      //Go on with the stuff
    } else {
      addMessage(FacesMessage.SEVERITY_ERROR,"Object not found");
    }       
  }
}

What am i doing wrong? And is this wrong use of JSF? I know i can generate a list and the click on the result but thats not what i want. Also i can take the barcode from the first bean and pass it as a parameter but i want the details page only to accept the id from the objects. So is my thinking wrong? Or is there a solution to get it like this?

  • 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-06-04T04:30:08+00:00Added an answer on June 4, 2026 at 4:30 am

    If I understand correctly, you wish to pass the ID of the barcode to the details page and yes this is possible.

    getFacesContext().getExternalContext().getRequestMap().put("id", data.getId()); 
    

    The following line is putting the ID parameter into the request that the client just sent you, but the navigation action to details will result in a different request. Try this instead:

    return "details?faces-redirect=true&id=" + data.getId();
    

    This will return an HTTP GET navigation action with the ID of the barcode passed as a request parameter in the request.

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

Sidebar

Related Questions

Hello i have the following problem, I record a video using red5 like this:
Hello I have a problem with the following code in a GTMTestCase: - (void)testSomething
Hello I have the following code namespace ConsoleApplication2 { class Program { static void
I have following code snippet: class ABC{ public: int a; void print(){cout<<hello<<endl;} }; int
I have the following form code: # forms.py class SomeForm(forms.Form): hello = forms.CharField(max_length=40) world
Possible Duplicate: NSNumber retain count issue Hello, I have the following code: NSNumber *number
I have the following code snippet. This is a c file in visual studio
I have the following problem. I need to pass the hello function to name
hello i have the following problem: i would like to create a filter for
Fellow JQuery hackers, hello :-) Suppose you have the following code: $('.links').click(function(){ //Do something

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.