CommandLink

CommandLink extends the standard h:commandLink with ajax, partial processing and confirmation features.

New Person
Ajax SubmitNon-Ajax Submit
Information
Firstname:
Surname:

Source

<h:form>

	<p:panel id="panel" header="New Person" style="margin-bottom:10px;">
		<p:messages id="messages"/>
		<h:panelGrid columns="3">
			<h:outputLabel for="firstname" value="Firstname: *" />
			<p:inputText id="firstname" value="#{pprBean.firstname}" required="true" label="Firstname">
				<f:validateLength minimum="2" />
			</p:inputText>
			<p:message for="firstname" />
			
			<h:outputLabel for="surname" value="Surname: *" />
			<p:inputText id="surname" value="#{pprBean.surname}" required="true" label="Surname"/>
			<p:message for="surname" />
		</h:panelGrid>
	</p:panel>

	<p:commandLink id="ajax" update="panel,display" actionListener="#{pprBean.savePerson}" style="margin-right:20px;">
		<h:outputText value="Ajax Submit" />
	</p:commandLink>

	<p:commandLink id="nonAjax" actionListener="#{pprBean.savePerson}" style="margin-right:20px;" ajax="false">
		<h:outputText value="Non-Ajax Submit" />
	</p:commandLink>
	
	<p:panel id="display" header="Information" style="margin-top:10px;">
		<h:panelGrid columns="2">
			<h:outputText value="Firstname: " />
			<h:outputText id="txt1" value="#{pprBean.firstname}" />
			
			<h:outputText value="Surname: " />
			<h:outputText id="txt2" value="#{pprBean.surname}" />
		</h:panelGrid>
	</p:panel>
	
</h:form>