f:commandButton and immediate attribute

I have a form with two fields. A field for street that should not be null and

a select box with two values that based on the chosen language the page gets values from two properties files.I would like the user when selects something from the select box to get the values from the properties file without validation for the first field.So I read that I should do 2 things.First I have to add the attributeimmediate in the componentselectOneMenu and then in the listener that is calls to add the following line

context.renderResponse()

.

The complete code of my jsp is:

<html>

<%@ taglib uri="http://java.sun.com/jsf/core" prefix ="f"%>

<%@ taglib uri="http://java.sun.com/jsf/html" prefix ="h"%>

<f:view>

<head>

<f:loadBundle basename="bundle.messages" var="msgs"/>

</head>

<body>

<h:form>

<h:panelGrid columns="3">

<h:outputText value="#{msgs.streetAddressPrompt}"/>

<h:inputText value="#{form.streetAddress}" id="streetAddress" required="true"/>

<h:message for="streetAddress"/>

<h:outputText value="#{msgs.countryPrompt}"/>

<h:selectOneMenu value="#{form.country}"

onchange="submit()">

<f:valueChangeListener type="com.corejsf.events.CountryListener"/>

<f:selectItems value="#{form.countryNames}"/>

</h:selectOneMenu>

</h:panelGrid>

<p/>

<h:commandButton value="#{msgs.submit}"/>

</h:form>

</body>

</f:view>

</html>

I read that context.renderResponse() skips validation.So if it does what why do I need the attributeimmediate which I understand that what it does is that fires the action event before validation.

[2336 byte] By [juanitaJa] at [2007-11-26 16:20:25]
# 1

I would like to ask and the following:

<h:selectOneMenu value="#{form.country}"

onchange="submit()">

<f:valueChangeListener type="com.corejsf.events.CountryListener"/>

<f:selectItems value="#{form.countryNames}"/>

If there was no submit() call in the onchange the method in the CountryListener (processValueChange) shouldn't be invoked?I add some debugs and when I remove the submit() call the CountryListener is not invoked.Why?A listener should be invoked when user activates in the compoment correct?

juanitaJa at 2007-7-8 22:44:00 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2

About the immediate attribute: check http://balusc.xs4all.nl/srv/dev-jep-djl.html to get some insights in the JSF lifecycle.

About the valueChangeListener and the submit(): well, if you remove the onchange="submit();" then you have to press/click a commandButton or commandLink to submit the form. The valueChangeListener method will only be invoked when the form is submitted.

BalusCa at 2007-7-8 22:44:00 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...