ModalPanel and Required Inputfields and ValidationPhaseListe
ahoehma Jan 30, 2008 1:09 PMHihi,
i have a modal panel with a required input field. the required field is loaded via a4j:include so the required field is independend from the "main-page".
Main-page:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:rich="http://richfaces.org/rich"
xmlns:a4j="http://richfaces.org/a4j"
xmlns:h="http://java.sun.com/jsf/html">
<h1>modal panel with wizzard</h1>
<rich:modalPanel id="test1_dlg">
<h:panelGroup columns="1">
<a4j:include viewId="wizzardContent.xhtml"/>
<h:outputText value="Close ME" id="test1_close" style="cursor: pointer;"/>
<rich:componentControl for="test1_dlg" attachTo="test1_close" operation="hide" event="onclick"/>
</h:panelGroup>
</rich:modalPanel>
<h:outputText value="Click ME" id="test1_click" style="cursor: pointer;"/>
<rich:componentControl for="test1_dlg" attachTo="test1_click" operation="show" event="onclick"/>
<h:form>
<h:inputText id="id"
required="true"
value="#{TestBean.id}"/>
<h:commandButton value="Submit"/>
</h:form>
<rich:messages passedLabel="Data is allowed to be stored." layout="list">
<f:facet name="header">
<h:outputText value="Entered Data Status:"></h:outputText>
</f:facet>
<f:facet name="passedMarker">
<h:outputText value="OK"></h:outputText>
</f:facet>
<f:facet name="errorMarker">
<h:outputText value="ERROR"></h:outputText>
</f:facet>
</rich:messages>
wizzardContent.xhtml:
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:a4j="http://richfaces.org/a4j"
xmlns:rich="http://richfaces.org/rich">
<rich:panel id="sample1" styleClass="tooltip-text">
<rich:messages passedLabel="Data is allowed to be stored." layout="list">
<f:facet name="header">
<h:outputText value="Entered Data Status:"></h:outputText>
</f:facet>
<f:facet name="passedMarker">
<h:outputText value="OK"></h:outputText>
</f:facet>
<f:facet name="errorMarker">
<h:outputText value="ERROR"></h:outputText>
</f:facet>
</rich:messages>
<h:form>
<h:inputText id="name"
required="true"
value="#{TestBean.name}"/>
<a4j:commandButton value="Submit"/>
</h:form>
</rich:panel>
</ui:composition>
TestBean is a simple session-bean with id and name properties.
Now the problem ;-) ... I want change the severity for missing required fields from error to warn ...
I found a blog http://jroller.com/ksevindik/entry/customizing_jsf_required_field_messages.
which describes how a RequiredFieldValidatorPhaseListener is called for every "required" UIInput-Component. Check if the component is required and has no value ... result ... create a errormessage.
But i want to create "warn"-messages instead of "error"-messages.
So i changed the code a little bit ... but the result was not working :( because the "hidden" required field "name" from the modal panel exists in the jsf-ui-tree. Hmmm ... is it possible to filter such a component?
regards
hoehmi[/url]