Note that there are some explanatory texts on larger screens.

plurals
  1. POSearch form that redirects to results page
    primarykey
    data
    text
    <p>Hello i have the following problem.</p> <p>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> <pre class="lang-xml prettyprint-override"><code>&lt;p:panelGrid columns="1" style="margin:20px;"&gt; &lt;h:form&gt; &lt;p:messages id="messages" globalOnly="true" showDetail="false" /&gt; &lt;p:message for="barcode" /&gt; &lt;p:inputText id="barcode" value="#{searchForm.barCode}" required="true" requiredMessage="Value needed" /&gt; &lt;p:commandButton value="search" action="#{searchForm.searchBarcode}" id="search"/&gt; &lt;/h:form&gt; &lt;/p:panelGrid&gt; </code></pre> <p>This is the backingbean:</p> <pre class="lang-java prettyprint-override"><code>@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&lt;Data&gt; 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"; } } </code></pre> <p>So if i go to my details page which expect the parameter id this isnt send to the detail page. </p> <p>backing bean details page:</p> <pre><code>@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"); } } } </code></pre> <p>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?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload