Page 1 of 1

Reset dialog content

Posted: 18 Sep 2011, 05:21
by tamizharasi
Hi,

I am displaying a dialog , in which datatable with checkboxes is displayed. I am having one submit button inside the dialog. After submitting the content of treetable< the backing bean will do some DB operation and the datatable content has to be reset.

I tried data.clear() data.resetValue(). Nothing is working and throwing JS error.

If anyone knows the method to set datatable value, please share...


I am using primefaces2.2 JSF 2.0 and JBOSS 4.2

Re: Reset dialog content

Posted: 18 Sep 2011, 10:52
by Cool Mr Ice
I'm new to this but may be able to help.

If by "reset" you mean update the table with your changes, you will need to make sure the getter for your datatable in the backing bean will return the correct data and then set update="data" on your submit button (assuming p:commandButton or ajax type submit). If you need to "reset" the sort/filter, you could use oncomplete="data.filter();" on your submit button.

Like I said before - full disclosure: I'm new to this.

Also, there is some code that shows what I'm talking about here: viewtopic.php?f=3&t=15061

I doesn't use a dialog, but there is a datatable that reacts to a commandButton in a similar fashion as you describe.

Re: Reset dialog content

Posted: 18 Sep 2011, 13:40
by tamizharasi
Hi,

Thx for your response.


I have done all the changes in my backing bean. But while again showing the dialog, two dialog boxes are opened. one with old content and another with new content.


The active is new content but how to vanish the old dialog box. For this issue I am breaking my head.

Re: Reset dialog content

Posted: 01 Feb 2012, 15:49
by priminator
Got the same problem. After trying around, solution is pretty simple. Just add a "<p:ajax event="close" update="myDialogId" />" in the dialog that references the id of the dialog itself.

Like this:

Code: Select all

	<p:dialog id="myDialog" modal="true" widgetVar="myDialog" dynamic="true" resizable="false" maximizable="false">
	    <p:ajax event="close" update="myDialog"/>
	    <h:form id="myForm" enctype="multipart/form-data">
			<h:panelGrid id="grid" columns="3" columnClasses="col1,col2,col3">
				<h:panelGroup><h:outputText value="Some Value"/></h:panelGroup>	
				<h:panelGroup><h:inputText id="someValue" value="#{myBean.someValue}"/></h:panelGroup>
				<h:panelGroup><p:message for="someValue" /></h:panelGroup>
			</h:panelGrid>
	        <p:commandButton value="#{messages.label_close}" onclick="myDialog.hide()" type="button" />
	    </h:form>
	</p:dialog>
It will reload the dialog html part and thus create and reference a new dialog.

Currently this works unter PF 3.0

Hope this helps!

Regards!