Primefaces datatable: what 'onRowSelectUpdate="display"' means? - java

I'm using the primefaces datatable and I've seen many times the onRowSelectUpdate event calling "display"?
What "display" means? is it a public method of the component or something?

It refers the ID of the component which is to be ajax-updated whenever you select a row. For example, a detail display.
<p:dataTable id="mytable" onRowSelectUpdate="mydisplay">
...
</p:dataTable>
...
<p:someComponent id="mydisplay">
<p>This component will be ajax-updated whenever a row is selected.
</p:someComponent>

From the PrimeFaces user guide, page 127:
Component(s) to update instantly after a row is selected.
Sounds like it works in the same way as the Ajax update attribute, but is activated when a row is selected in a data table. I've never used it myself so I don't have any code samples to share.

Related

Table is not being refreshed after valueChangeListener is executed

I have a table that shows info from a backing bean's list attribute.
I also have a selectOneRadio that clears that list on its valueChangeListener.
Finally the table should show empty after that valueChangeListener but it keeps showing the previous info.
This is the key components in my jsp file:
The selectOneRadio:
<tr:selectOneRadio id="selectValue"
value="#{myBean.value}"
autoSubmit="true"
valueChangeListener="#{myBean.changeValue}"
layout="horizontal">
<f:selectItems value="#{myBean.values}" />
</tr:selectOneRadio>
The table:
<trh:tableLayout inlineStyle="width: 100%;" partialTriggers="selectValue">
<tr:table partialTriggers="selectValue"
id="tableResults" var="var" emptyText="No records" width="100%"
value="#{myBean.listInfo}"
selectedRowKeys="#{myBean.selectedElements}"
rowBandingInterval="1" rowSelection="multiple">
As I said, when I click the radio button the method changeValue(event) of MyBean is executed clearing the listInfo list but the table keeps showing the elements that were in the list dispite of the partialTriggers attribute.
What is wrong with this approach? Is there another way to refresh the table so it will display empty after clicking the radio button?
Thanks very much.
By removing the enclosing tableLayout tag the table gets refreshed properly as espected of partialTriggers.
I don't understand why was this happening and it would be nice if anyone can explain it but I consider the question closed.

Wicket Table css not rendered after ajax update?

I have a datatable with some items. The datatable has some css on the table tag. When I update the dataproviders model list and send the component back with ajax the css doesn't get rendered.
However if I send the entire page using ajax the table is rendered correct.
Example:
<wicket:panel>
<table class="striped">
</table>
</wicket:panel>
This css class gives odd and even a different css.
This is how I update the component after changing the dataprovider.
ajaxRequestTarget.add(MyPage.this.get("myPanel")); //this panel contains the table
The data gets added but the css markup is gone.
Refreshing the page brings back the css.
ajaxRequestTarget.add(MyPage.this); //send the entire page
This works but the entire page gets refreshed(and this make the page scroll up.
Whats the difference in component rendering if you send the entire page, instead of only 1 component/panel?
I'm using chrome.
If you render styles via jQuery, you'll have to call it again to re-paint correctly.
ajaxRequestTarget.appendJavascript("renderMethod('.striped');");

Call listener by clicking pencil (primefaces 2.2.1 rowEditor)

How can I call listener after clicking pencil on rowEditor?
I want to prepare text from dataTable for editing (clear html tags for tabs and return carriages).
Do you have any ideas?
Thank you.
Actually,there is no event for pencil in datatable.If you want to call listener after pencil click,you can do like that.Wrap rowEditor into commandLink.I did and it works.
<p:commandLink id="rowEditLink" action="#{teamMB.initCombo}" ajax="true"
update=":formContent:teamTable>
<p:rowEditor />
</p:commandLink >
This won't work for version 2.2.1, but it can still be relevant for others
2 year old question but it's one of the top Google results.
There is a way to do this without using <p:commandLink>
The Primefaces User Guide on page 154 talks about ajax events. There are three events of interest rowEdit, rowEditInit, rowEditCancel.
rowEditInit is the event that triggers when a row switches to edit mode
rowEditCancel is the event that triggers when a row edit is cancelled
So your code should look like this
<p:ajax event="rowEditInit" listener="#{tableBean.onEditInitCleanUp}" update="#form">
Then your listener would do the appropriate clean up.

Display the Hindi encoded values in my select box

I am working on struts framework in java and I have a jsp which has a select box. Onchange of this select box I am displaying some values in a second select box. The first select box is displaying the Hindi characters properly. I select some value and the onchange function is called and it goes to ajax and gets the values in second select box. THe second select box is displaying question marks.The follwing is the jsp code
District(ज़िला)
Municipality(नगर)
<html:select property="municipalitycode" bundle="utf-8"
styleId="mun_List" style="width:180px;"
onchange="getzones('myajax.do?action=getzones',this);getsections('myajax.do?action=getsections',this);">
<html:option value="">Select</html:option>
<html:optionsCollection property="municipalities" />
</html:select>
</tr>
Onchange of district, I get muncipalities.
Please help?
Character encoding can be quite tricky, make sure you haven't missed out on anything.
Refer the link below:
http://balusc.blogspot.com/2009/05/unicode-how-to-get-characters-right.html

rich:dataScroller how to switch pages every 10 seconds?

I have a rich:dataTable with dataScroller. In each page I need to show 5 records. Record count dynamically changes. I refresh dataTable every 20 seconds to see if there is any new record.
If there are more than 5 records, dataTable will have two or pages.
If there are more than one pages for dataTable, is it possible to say dataScroller to switch pages every 10 seconds? After it shows last page then it should back to first page.
Thanks
Well, you can bind dataScroller with the bean (using de prop. "binding") and use a javascript to "click a invisible button" that executes a bean function to go to the next page..
Xhtml:
<script type="text/javascript">
var t;
t=setTimeout("timedCount()", 1000);
function timedCount() {
document.getElementById('formName:button').click();
t=setTimeout("timedCount()", 10000);
}
</script>
(...)
<h:commandButton id="button" action="#{bean.scrollNext}" reRender="tableID"
style="visibility:hidden;"/>
(...)
Bean:
HtmlDataScroller scroll; //(im not sure about the "HtmlDataScroller")
(...)
public void scrollNext() { scroll.next(); }
(...)
//Gets and sets to bind the scroller
get; set;...
Dont forget to make a new instance of htmlDataScroller or you'll get a nullPointException..
I guess this is not impossible. Please try to have a look into a4j:poll component. Will try and hopefully post more updates
AFAIK, this is not possible with default richfaces. I think you will be able to refresh the data in your table periodically using <a4j:poll>, but not the automatic page-switching.
However, the <rich:datascroller> has a client-side API (which is described here).
Combining this with javascript timing may be the way to get the page-switching working.

Categories

Resources