Update growl for p:wizard step?

UI Components for JSF
Post Reply
madmis
Posts: 19
Joined: 13 Sep 2011, 18:00
Location: Ukraine => Kiyv

20 Sep 2011, 11:01

Hi all!

Code: Select all

	<p:growl id="growl" showDetail="true" sticky="true" />
	<h:form id="signupForm">
		<p:wizard widgetVar="wiz"
				  flowListener="#{signup.onFlowProcess}"
				  showStepStatus="false">
			<p:tab id="step1" title="Main">
				<h:outputText value="Email: *" />
				<p:inputText id="mnemo"
							 required="true"
							 value="#{signup.posData.mnemo}"
							 maxlength="30">
				</p:inputText>
			</p:tab>
			<p:tab id="step2" title="Next">
				...
			</p:tab>
		</p:wizard>
	</h:form>
When user insert Email and press NEXT button, i need check email in database. If email is isset, i need update "growl" with the appropriate message.

Code: Select all

	public String onFlowProcess(FlowEvent event) {
		if (issetEmail()) {
			FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_INFO,"Email isset", "Email isset"));
			RequestContext requestContext = RequestContext.getCurrentInstance();
			requestContext.addPartialUpdateTarget("growl");
			return event.getOldStep();
		}
		return event.getOldStep();
	}
requestContext.addPartialUpdateTarget("growl"); - but this not work.

Please help!!! How to do it properly?

primefaces-3.0.M3.jar, JSF 2.0, apache-tomcat-6.0.32

madmis
Posts: 19
Joined: 13 Sep 2011, 18:00
Location: Ukraine => Kiyv

20 Sep 2011, 14:49

Prime, answer me please - why not work requestContext.addPartialUpdateTarget("growl") in this code?
NetBeans 7.0.1, apache-tomcat-6.0.32, Java EE 6, Mojarra 2.1.4 (JSF 2.1), primefaces-3.0.M4, apache-tomcat-6.0.32

madmis
Posts: 19
Joined: 13 Sep 2011, 18:00
Location: Ukraine => Kiyv

21 Sep 2011, 09:59

I do this. Can someone come in handy.

Code: Select all

	<h:form id="signupForm" prependId="false">
		<p:wizard widgetVar="wiz"
				  id="signWiz"
				  style="width: 600px; margin: 0 auto;"
				  flowListener="#{signup.onFlowProcess}"
				  showStepStatus="false"
				  onnext="$(this).doWizard();">
			<p:tab id="step1" title="Main">
				<p:panel header="Main">
					<h:panelGrid columns="2" style="margin-bottom:10px;" cellpadding="5" cellspacing="5">

						<h:outputText value="Email: *" />
						<p:inputText id="mnemo"
									 required="true"
									 value="#{signup.posData.mnemo}"
									 maxlength="30">
						</p:inputText>
					</h:panelGrid>
				</p:panel>
				<p:commandButton id="stepButton1"
								 actionListener="#{signup.stepValidate}"
								 style="display: none;"
								 update="growl">
				</p:commandButton>
			</p:tab>
			<p:tab id="step2" title="Addt">
				<p:commandButton id="stepButton2"
								 actionListener="#{signup.stepValidate}"
								 style="display: none;"
								 update="growl">
				</p:commandButton>
			</p:tab>
			<p:tab id="step3" title="Address">
						<p:commandButton id="stepButton3"
										 value="Register"
										 actionListener="#{signup.stepValidate}"
										 update="growl"
										 styleClass="f-right" />
			</p:tab>
		</p:wizard>
	</h:form>
	<script type="text/javascript">
		$.fn.doWizard = function() {
			$('button[name*="stepButton"]').trigger('click');
		};

		$(function() {});
	</script>

And Bean

Code: Select all

private boolean nextStep = false;

	public void stepValidate(ActionEvent event) {
		CommandButton cb = (CommandButton) event.getSource();
		String clId = cb.getClientId();

		if (clId != null && clId.equals("stepButton1")) {
			this.validateStep1();
		} else if (clId != null && clId.equals("stepButton2")) {
			this.setBirthDay();
			this.validateStep2();
		} else if (clId != null && clId.equals("stepButton3")) {
			this.insertSQL();
		} else {
			Utils.addFacesMessage(FacesMessage.SEVERITY_ERROR, "mess", "mess");
		}

		//RequestContext requestContext = RequestContext.getCurrentInstance();
		//Utils.addFacesMessage(FacesMessage.SEVERITY_ERROR, "mess", "mess");
		//requestContext.addPartialUpdateTarget("growl");
	}

	private void validateStep1() {
		this.nextStep = false;

		if (!ValidateUtils.isValidEmailAddress(this.posData.getMnemo())) {
			Utils.addFacesMessage(FacesMessage.SEVERITY_ERROR, "Email", "mess");
		} else if (this.issetUserEmail()) {
			Utils.addFacesMessage(FacesMessage.SEVERITY_ERROR, "Email", "mess");
		} else if (!this.posData.getPassword().equals(this.posData.getC_password())) {
			Utils.addFacesMessage(FacesMessage.SEVERITY_ERROR, "Confirm password", "mess");
		} else {
			this.nextStep = true;
		}
	}

	private void validateStep2() {
		this.nextStep = false;
		if (this.checkBirthDay && posData.getBirthday() == null) {
			Utils.addFacesMessage(FacesMessage.SEVERITY_ERROR, "BirthDay", "mess");
		} else {
			this.nextStep = true;
		}
	}

sabrina.bettini
Posts: 2
Joined: 17 May 2012, 15:06

03 Aug 2012, 13:46

Have you tried putting your p:growl inside the form?

madmis
Posts: 19
Joined: 13 Sep 2011, 18:00
Location: Ukraine => Kiyv

03 Aug 2012, 13:52

sabrina.bettini wrote:Have you tried putting your p:growl inside the form?
I don't remember. Now i havn't access for this sources.
NetBeans 7.0.1, apache-tomcat-6.0.32, Java EE 6, Mojarra 2.1.4 (JSF 2.1), primefaces-3.0.M4, apache-tomcat-6.0.32

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 26 guests