1

I am using JSF 1.2 and RichFaces 3.3.3, and I have a very strange issue, what the code does is take the name of the media item to be searched and put it in the backing bean attribute searcTitle, and when the user clicks the search button the onSearch action listener populates the results list.

And here's the code

<rich:panelBar>
   <rich:panelBarItem>
       <rich:tabPanel>
           <rich:tab label="Media">
              <h:panelGrid columns="1">
                 <h:panelGrid columns="2">
                   <h:inputText value="#{media.searchTitle}"/>
                   <a4j:commandButton value="Search" actionListener="#{media.onSearch}"/>
                 </h:panelGrid>
                 <a4j:outputPanel id="mediaSearchResults" ajaxRendered="true">
                    <rich:dataTable value="#{media.results}" var="item">
                       <h:column>
                          <h:outputText value="#{item.title}"/>
                       </h:column>
                    </rich:dataTable>
                 </a4j:outputPanel>
              </h:panelGrid>
           </rich:tab>
       </rich:tabPanel>
   </rich:panelBarItem>
</rich:panelBar>

And the backing bean code

private String searchTitle="";
private List<MediaItem> results;

public void setSearchTitle(String title){
    getLogger().log(Level.INFO,"At the setter of the search title string"); 
    this.searchTitle = title;
}

public String getSearchTitle(){
    return searchTitle;
}
//Setter and getter for the results list;

//Action Listener
public void onSearch(ActionEvent evt){
   getLogger().log(Level.INFO,"At the actionListener"); 
   //Some function that searches and populates the results list
   populateResults();
}

Now the problem is whenever I click on the search button, the action listener is never called, although while inspecting the page with fire bug a request is sent to the server everytime I click on it, but the action listener itself is not triggered.

Does anyone have a clue why I'm having this issue? I'm a beginner at this, so please keep your words simple.

Thanks in advance.

Here are the Reposne/ Request headers from firebug

Response Headers

Ajax-Response   true
Cache-Control   no-cache, must-revalidate, max_age=0, no-store
Content-Type    text/xml;charset=UTF-8
Date    Sat, 02 Jun 2012 16:03:13 GMT
Expires 0
Pragma  no-cache
Server  Sun GlassFish Enterprise Server v2.1.1
Transfer-Encoding   chunked
X-Powered-By    Servlet/2.5, JSF/1.2

Request Headers

Accept  text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Encoding gzip, deflate
Accept-Language en,ar;q=0.7,en-us;q=0.3
Connection  keep-alive
Content-Length  17986
Content-Type    application/x-www-form-urlencoded; charset=UTF-8
Cookie  JSESSIONID=de975352b3adc4f59d57006755ea; JSESSIONID=de682f835c0fa928413ba7e5f59d; form:tree-hi=form:tree:applications:enterpriseApplications
Host    localhost:8080
User-Agent  Mozilla/5.0 (Windows NT 6.1; WOW64; rv:12.0) Gecko/20100101 Firefox/12.0

And the link to the xml payload of the response http://justpaste.it/10uh

mprabhat
  • 20,107
  • 7
  • 46
  • 63
Sabry Shawally
  • 603
  • 2
  • 11
  • 24
  • Your request contains 2 session cookies. This doesn't look right and might be a possible cause of your problem. Restart the browser or clear the cookies and retry. – BalusC Jun 02 '12 at 16:33
  • I did try that, and restated the app itself but with no use – Sabry Shawally Jun 02 '12 at 16:41
  • Well, then work through this list of all possible causes: http://stackoverflow.com/questions/2118656/hcommandlink-hcommandbutton-is-not-being-invoked The possible cause is not visible in the code posted so far. If you can't figure out based on the list, then you'd need to edit your question to include a real SSCCE instead instead of only a partial snippet. – BalusC Jun 02 '12 at 16:43

1 Answers1

2

You should try a f:form or a4j:form around your a4j:commandButton.

Thor
  • 6,607
  • 13
  • 62
  • 96