0

I am using this ajax call in jsf

jQuery.ajax({

    url: '#{UserBean.searchUser}',
    type: 'POST',
    data: { firstName: firstName },
    success: function(data) {
        // render table
    },
    error: function(request, status, error) {
        //error description
    },
});

here i am getting success, that means the action is called. I want to retrieve the User list from action, how the list will be send from action? after returning data i want to render all the data in table, format is :

<h:dataTable 
    var="o"
    id="tblResult" 
    cellpadding="10px" 
    cellspacing="0px" 
    styleClass="searchTable">

    <h:column>
        <f:facet name="header">
        <h:outputText value="Student Name" />
    </f:facet> 
        <h:outputText value="User1" />
    </h:column>

    <h:column>
        <f:facet name="header">
            <h:outputText value="Student Id" />
        </f:facet>
            <h:outputText value="user1" />
    </h:column>
</h:dataTable>

I am unable to use

<f:ajax />

since my pages are .jsp.

3
  • I do not know what you are trying to accomplish and whether you need Jquery in this, but have you ever looked at <f:ajax event="" /> tags?
    – Menno
    Oct 18, 2012 at 13:15
  • yes, but this <f:ajax event="" /> is not working, since my all pages have an extension of .jsp. <f:ajax event="" /> supports .xhtml. Oct 19, 2012 at 4:15
  • Are you using JSF 2.0 or an earlier version, because JSP files are deprecated since 2.0.
    – Menno
    Oct 19, 2012 at 8:06

1 Answer 1

0

This is not going to be easy if you're already asking this question.

You basically need to create a custom Ajax aware ViewHandler and a custom XML ResponseWriter and custom tags which generates the desired JavaScript code to perform the XMLHttpRequest works and HTML DOM manipulation. This is also what most of all those 3rd party JSF 1.x component libraries already have done for you. They are all open source, so you could just take a peek in its source code to learn-by-example how they did it. But this requires solid knowledge and understanding of how HTTP, HTML, XMLHttpRequest and JSF lifecycle works. And if you're already asking this question ...

I strongly recommend to just migrate from JSP to Facelets. JSP is deprecated since JSF 2.0 and all new JSF 2.0 tags/features are not available for JSP, but for Facelets only. Also all JSF 2.0 compatible component libraries do not support JSP anymore.

See also:

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.