MasterDetail - ContextVar null after postback

Community Driven Extensions Project
Post Reply
djmj
Posts: 400
Joined: 16 Dec 2011, 01:23

08 Nov 2015, 20:26

Primefaces: 5.3
Extension: 4.0.0
Glassfish: 4.1
Mojarra: 2.2.9

I want to toggle visibility of form inputs depending on existence of child property Bar.

The GUI supports adding a new Bar instance or deleting it.

Code

I have a simple entity with a child property Bar like:

Code: Select all

	class Foo
	{
		private String name;
		private Bar bar;

		public void initBar()
		{
			if (this.bar == null)
				bar = new Bar();
		}
	}
Within MasterDetail i have following form to toggle the child property Bar:

Code: Select all

	<pe:masterDetailLevel level="2" contextVar="contextVarFoo" levelLabel="#{foo.name}">
		<h:panelGroup id="pnlBar">
			<!-- create Bar -->
			<p:commandButton icon="ui-icon-plusthick" rendered="#{contextVarFoo.bar eq null}"
				action="#{contextVarFoo.initBar()}"
				process="@this" update="pnlBar"/>
			<ui:fragment rendered="#{contextVarFoo.bar ne null}">
				<!-- input components for Bar -->
				<!-- remove Bar -->
				<p:commandButton icon="ui-icon-closethick" 
					process="@this" update="pnlBar">
					<f:setPropertyActionListener value="#{null}" target="#{contextVarFoo.bar}"/>
				</p:commandButton>
			</ui:fragment>
		</h:panelGroup>
	</pe:masterDetail>

The Bar toggling markup is working outside of MasterDetail.
But inside MasterDetail I can only once remove the current instance via AJAX and on next AJAX request contextVar is null.
Primefaces: 11.0.0 RC2
Primefaces-Extension: 11.0.0
PrimeFaces-Mobile: 11.0
OmniFaces: 3.11
Jsf: Mojarra 2.3.8
Server: Glassfish 5.1.0

Post Reply

Return to “Extensions”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 12 guests