I am using JSF 2 with PrimeFaces 2.2. I tried making an ajax call through a select box onchange event in a dataTable. I was able to see the System.outs printing but, I could not see the components given in the update attribute getting updated. I have given the dataTableId in the update attribute.
I guess the problem now is the selectbox is getting populated again and an ajax call is made. Should we give only the parent tags in the update attirbute, for the ajax call to work. Please help me out in this.
When the ID in the update attribute does not start with :, it becomes relative to the ID of the current component inside the same NamingContainer component. But since the h:dataTable is an NamingContainer component, you need to reference it by an absolute ID. Rightclick the JSF page in the webbrowser and choose View Source to see the generated HTML DOM tree. Locate the HTML <table> element which is generated by the <h:dataTable>, determine the value of its id attribute and use exactly that id in the update attribute, prefixed with :.
Related
If you do JSF AJAX calls and change the component tree while rerendering (or between ajax calls), you'll get exceptions from Mojarra. As I understand it, it's difficult to recreate the component tree partially when the new tree is different as the one stored in the ViewState (or the actual JSF class). That's "ok". I'm thinking about using the rendered attribute and not rendering the component.
My question: How does the rendered attribute work? Does the component get restored and is the component tree, that JSF creates during restore phase, safe? We have a very dynamic XHTML page and not rendering object's instead of disabling them with css classes would really up the speed of the page.
I tried it and it works as expected. So JSF only assumes that the component is there even if it doesn't render anything.
Please consider that the view state does get restored and it's still a performance hit (but a smaller one as nothing get's sent over the wire and the output string/html doesn't need to be rendered).
I've a paginated OpenFaces 3 datatable (using o:dataTablePaginator within a facet below the table) that has a column which contains an a4j:jsFunction tag (using RichFaces 4.1) to create (a differently named) JavaScript function within each row of the table. The JSF 2.1 page which contains the table is being deployed within an application onto Glassfish 3.1.
When I click the next page icon for the table, the datatable fails to update via AJAX with the OpenFaces AJAX "Loading..." message (with the "spinning" diamond) remaining displayed in the top right corner of the page. In Firebug, I can see the result of the OpenFaces AJAX Post being an error with the affected line 344 of ajaxUtil.js:
TypeError: xml.getElementsByTagName("partial-response")[0] is undefined
var childNodes = xml.getElementsByTagName("partial-response")[0].childNodes;
and the following error in IE Developer Tools:
SCRIPT5007: Unable to get value of the property 'childNodes'
: object is null or undefined
I've been able to eliminate all other tags within the datatable being the cause of the problem except for this one:
<a4j:jsFunction id="cellUpdateFunction#{rowIndex}"
name="updateCellStr#{rowIndex}"
data="#{backingBean.getStrForRow(rowIndex)}" execute="#this"
oncomplete="setCellText(#{rowIndex}, event.data);"/>
This creates a JavaScript function in a column cell (for each row of the table) that when called updates the text in the cell with the string stored for the cell within the backing bean.
Does anyone know whether this is a known issue and there is a workaround I've been unable to find? Otherwise, how would I go about writing similar functionality with OpenFaces AJAX as I expect that using only OpenFaces components would not break the AJAX call updating the OpenFaces datatable?
Thanks in advance for any help.
Can you try to use the nightly builds and check? You can find nightly builds here: http://openfaces.org/downloads/
I use primefaces and the dataTable component. On my Site i have several forms which i use to collect Data and persist it in the Database. This is triggered by a p:command Button, which Attribute “Update“ contains the id of the dataTable showing the DB contents. When i submit the Form the component (table) is Not updated. What could be wrong?
not an answer but a question to help divine the point of failure. is the datatable in a separate form from the commandButton? if so, assuming you're using ajax="true" (the default for pf components), how are you referencing the table to make sure it updates. if you're not using ajax, i'm guessing it's a stale data issue in the backing bean. but without more info, it's hard. try attaching source code (stripped down to your comfort level if you're working on something sensitive).
HTH
I have a hyperlink column in the grid. On clicking the link i have to hide the partialview(grid section) and have to show/load another partialview which is the detail section. Please provide solution
You could use javascript. With jQuery that will correspond to the .toggle() function or the .show()/.hide() functions. So basically you will subscribe to the click event of the link and inside this handler show and hide the respective sections. For this to work you should obviously place those partials inside placeholder divs so that you could show/hide the entire placeholder.
If in addition to showing the partial you need to fetch some fresh information from the server then you could use AJAX to request a controller action that will return the fresh data of the partial view that you will inject into the DOM at the correct placeholder location. In order to send an AJAX request in jQuery you could use the $.ajax() function or directly the .load() function.
I am unable to set value of text, radio and other form elements based on a select element onchange.
All form elements are part of the same form.
The values to be set are to be fetched from database table without refreshing/redirecting the whole page (may be using Ajax).
Solution should be MVC based. I am a ZF novice.
Made it work with the help of following link:
http://zendgeek.blogspot.in/2009/07/ajax-with-json-and-prototype-in-zend.html
I used JQuery $.ajax() in place of prototype.js Ajax.Request() as the latter was conflicting somewhere with a datepicker element and I thought why to include one more js file when already JQuery is there.