Primefaces Dialog and Closable events

UI Components for JSF
Alex
Posts: 256
Joined: 16 Dec 2010, 14:24
Location: Germany

27 May 2011, 14:58

hi, sorry have to focus on some other things..

yes i am facing the same in our application.. even harder, because we have a NPE which results the dialog not loaded fully and get stuck in the app..

i do not have a solution for this.. it must be some behaviour of the jsf validations..
in my case i also do a reset all objects by a actionmethod and initialise them again by reopening, but the validation seems to hold the old fields and their data..

ill post into the enterprise board to ask cagatay for support in this
PrimeFaces 3.2
Mojarra 2.0.2
Glassfish 3.0.1

User avatar
Hericksnake
Posts: 47
Joined: 21 Jan 2011, 22:45
Location: Brasil

27 May 2011, 15:17

Thanks for your reply.
Please, let me know if you find a solution.

Regards,

Herick
Primefaces 3.2
JSF 2.0
Glassfish Server 3.1.2
Netbeans7.1.1

rasman
Posts: 12
Joined: 12 Jun 2011, 00:36

14 Sep 2011, 11:34

Hi

I have been having the same problem as described in this topic and have yet to find a solution.

Did you manage to solve it?

Regards
Rasman
Primefaces 3.3.1.M3, Mojarra 2.1.3, SEAM Faces 3.0.2.Final, JBoss AS 7.0.Final

User avatar
Lawyno
Posts: 9
Joined: 19 May 2011, 11:33

14 Oct 2011, 15:51

Hi,

I've found a solution, which works for me.

I don't know if I understand your problem exactly, but I'm gonna share it here in case it might help you, too ;)

This is my Dialog:

Code: Select all

<p:dialog id="myDialog" widgetVar="myDialog" modal="true">
	
	<p:ajax event="close" listener="#{itemController.initNewItem}"
				update="myDialogForm" immediate="true" global="false"
				oncomplete="MyUtils.removeErrorStates('myDialogForm');" />
	
	<h:form id="myDialogForm">
		
		<p:message for="newItemName" />
		<p><h:outputText value="${uiText['dlgNewItem']}" /></p>
		
		<h:panelGrid columns="2">
			<h:outputLabel value="#{uiText['lblName']}:" />
			<p:inputText id="newItemName" required="true"
						value="#{itemController.newItem.name}"
						requiredMessage="#{uiText['msgRequiredField']}" />
		</h:panelGrid>
		
		<h:panelGrid columns="2">
			<f:facet name="footer">
				<p:commandButton value="#{uiText['cmdOk']}"
							actionListener="#{itemController.createNewItem}"
							oncomplete="myDialog.hide();"
							update="@form :msgs">
				</p:commandButton>
				<p:commandButton value="#{uiText['cmdCancel']}"
							onclick="myDialog.hide();" type="button" />
			</f:facet>
		</h:panelGrid>
		
	</h:form>
	
</p:dialog>
The ItemController:

Code: Select all

@SessionScoped
@Named
public class ItemController implements Serializable
{
	private static final long serialVersionUID = 1L;
	
	
	private Item newItem;
	
	// ...
	// getter,
	// setter,
	// etc.
	// ...
	
	public void initNewItem()
	{
		newItem = new SampleItem();
	}
	
	@PostConstruct
	public void init()
	{
		initNewItem();
	}
}
My JavaScript function:

Code: Select all

MyUtils.removeErrorStates = function(id)
{
	$(PrimeFaces.escapeClientId(id) + ' .ui-state-error').removeClass('ui-state-error');
};
ItemController.initNewItem() creates a new item (with empty values) for the form of MyDialog.
MyUtils.removeErrorStates() simply removes the CSS class "ui-state-error" from all elements inside the element with the given "id", which, in this case, is the form of MyDialog.

The p:ajax does all this in the correct order (first reset the form data, then, after the update, remove the remaining error state).

Now the dialog looks like the first time :)

... at least in my project ;)


Regards,

Lawyno
Primefaces 3.0.RC2/3.0-SNAPSHOT - Mojarra 2.1.3 - JBoss AS 7.0.2.Final/Glassfish 3.1.1

spotted_dog
Posts: 2
Joined: 02 May 2012, 18:56

02 May 2012, 19:02

So I am having this issue too. I have tried the above solution but with no resolution (the problem still exists).

Has anyone else been able to confirm if the above solution worked for them?

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 17 guests