Ahh, I see. Many thanks for your help Jeff. I'll test this.

Michael



-----Original Message-----
From: Jeff Bischoff [mailto:[EMAIL PROTECTED] 
Sent: Donnerstag, 22. Juni 2006 16:00
To: MyFaces Discussion
Subject: Re: selected value and immediate submits

Michael,

My valueChangeListener gets called before they even click on the 
commandLink. As soon as they pick something new in the select menu 
drop-down box, the onchange="submit()" causes the form to submit. This 
fires the valueChangeListener (along with any other "immediate" 
listeners on the form). The call to context.renderResponse prevents the 
rest of the JSF lifecycle from continuing, thus skipping validation etc.

Now they are still seeing the same page, nothing has visually changed. 
But the model has been updated with the new value, and it is sitting 
there waiting and ready for when they click that commandLink.

Regards,

Jeff Bischoff
Kenneth L Kurz & Assoc, Inc.

Michael Heinen wrote:
> Thanks Jeff.
> 
> Was your valueChangeListener called although you used an immediate
> commandLink ?
> 
> -----Original Message-----
> From: Jeff Bischoff [mailto:[EMAIL PROTECTED] 
> Sent: Donnerstag, 22. Juni 2006 15:30
> To: MyFaces Discussion
> Subject: Re: selected value and immediate submits
> 
> Michael,
> 
> I have the same functionality in my application. (Or rather I used to,

> before I started using subForms ;) I used the following:
> 
> <h:commandLink action="#{search.doSearch}" immediate="true">
>       <h:graphicImage.../>
> </h:commandLink>
> 
> <h:selectOneMenu value="#{search.searchOption}"
>                onchange="submit()" immediate="true"
>                valueChangeListener="#{search.updateSearchOption}">
>       <f:selectItems.../>
> </h:selectOneMenu>
> 
> 
> And in updateSearchOption() I have this:
> 
> public void updateSearchOption(ValueChangeEvent event) {
>       String newOption = (String)event.getNewValue();
>       this.setSearchOption(newOption);
>       ...
>       FacesContext context = FacesContext.getCurrentInstance();
>       context.renderResponse();
> }
> 
> Regards,
> 
> Jeff Bischoff
> Kenneth L Kurz & Assoc, Inc.
> 
> Michael Heinen wrote:
> 
>>Hi,
>>
>> 
>>
>>I asked this question a few months ago but I didn't get an answer. So
> 
> I 
> 
>>try it again because I have to solve this now.
>>
>> 
>>
>>I have a selectOneMenu and a link beside it. When the user clicks the 
>>link I need the selected value in my BackingBean without form 
>>validation. The target of the link is an iframe and I don't want that 
>>the same page with error messages is rendered in this iframe.
> 
> Therefore 
> 
>>the immediate attribute of the link is set true.
>>
>>I can't use a ValueChangeListener because this is not called with 
>>immediate submits, right?
>>
>> 
>>
>>Can I use an updateActionListener and set the selected value via 
>>javascript (see snippet and the '???')
>>
>> 
>>
>>Or is the usage of a component binding for the selectOneMenu the only 
>>working alternative?
>>
>> 
>>
>> 
>>
>>Snippet:                      
>>
>><t:selectOneMenu id="documentTypeId" forceId="true"
>>
>>     value="#{MyBean.document.attributes['documentTypeId']}">
>>
>>   <f:selectItems value="#{MyBean.scoredCategories['documentType']}"/>
>>
>></t:selectOneMenu>
>>
>>                       
>>
>><h:commandLink action="#{MyBean.switchHighlighting}" immediate="true" 
>>target="zone1">
>>
>>   <t:updateActionListener property="#{MyBean.selectedDocumentTypeId
> 
> }" 
> 
>>value="????"/>
>>
>>   ...
>>
>></h:commandLink>
>>
>> 
>>
>>Thanks in advance,
>>
>>Michael
>>
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 






Reply via email to