0

I have a search bar with a Dropdown (for user to choose) and an Input Text to display details of a data. The flow is like this;

  1. The user will pick either one of the two options from the dropdown (Range Id, Awb)
  2. User then have to enter an ID in the inputText and then click on the searchButton which go to doSearch to eventually display the details of the entered ID on screen.

If the ID I entered are valid, I am able to view the respective pages. However, I notice that when the first ID is invalid, it gives back the correct invalid message (idNotValid.show()) but after that when I change the value of dropdown without refreshing the page, the dropdown value is not updated and doesn't refresh/restart the whole process of doSearch.

Navigation.xhtml

<h:panelGroup> 
  <h:selectOneMenu id="option" value="#{viewRangeClassBean.selectOption}" style="width:80px">
    <f:selectItem itemLabel="Range ID" itemValue="A" />
    <f:selectItem itemLabel="Awb" itemValue="B" />
  </h:selectOneMenu>
  <p:inputText id="search" value="#{viewRangeClassBean.rangeId}" style="width:100px"
  onkeypress="if (event.keyCode == 13) { 
  document.getElementById('navigationForm:searchButton').click();} "
  converterMessage="#{msg['Dims.numericConverterMsg']}"></p:inputText>
  
  <p:commandButton value="#{msg['.GoButton']}" id="searchButton" action="# 
  {viewRangeClassBean.doSearch}" oncomplete="if(args.ridNotFound){ridNotFound.show()} else 
  if(args.idNotFound){idNotFound.show()} else if(args.idNotValid){idNotValid.show()}" />
</h:panelGroup>

ViewRangeClassBean.java

public String doSearch() throws DimsApplicationException {
        Long rangeIdLong;
        // Check for input range and option selected
        if (null != rangeId) {
            if ("A".equals(selectOption)) {
                // search by complete id
                try {
                    rangeIdLong = Long.parseLong(rangeId);
                } catch (NumberFormatException e) {
                    RequestContext.getCurrentInstance().addCallbackParam("idNotValid", true);
                    return "null";
                }
                return searchRangeId(rangeIdLong);
            } else if ("B".equals(selectOption)){
                // Searching by awb
                return searchIdentifier(loginBean.getCurrentIdentifier());
            } else {
                return null;
            }
        } else {
            return null;
        }
    }
Jasper de Vries
  • 16,868
  • 6
  • 60
  • 93
Wani M
  • 21
  • 1
  • Please read https://stackoverflow.com/questions/25339056/understanding-primefaces-process-update-and-jsf-fajax-execute-render-attributes – Jasper de Vries Feb 21 '22 at 14:33

0 Answers0