Hello, 

I want to change some values of a backing bean through a
valueChangeListener, and then show the results to the user. 
The use case is: 

Address (Managed Bean - Session scope) 
OrderView (Managed Bean - Request scope)

JSP snippet: 
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
<x:inputText value="#{address.searchcode}"
valueChangeListener="#{orderView.processSearchcodeChange}"
        immediate="true"
        onchange="submit()"/>

<x:inputText value="#{address.name}">
        <f:validateLength minimum="5"/>
</x:inputText>
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- // End JSP Snippet

Code snippet: 
=-=-=-=-=-=-=-=-=-=-=-=-=-=-
public class OrderView..
   private Address address; 
   
   public void processSearchcodeChange(ValueChangeEvent event){
       String searchText = (String) event.getNewValue();
       Address result = SomeAddressDAO.getAddress(searchText);
       address.setName(result.getName());
         
         // Go to the renderresponse phase, else the values will be
overwritten
         // in the update model phase
         FacesContext context = FacesContext.getCurrentInstance();
         context.renderResponse();
   }

        
   // Address is injected using managed properties! (faces-config.xml)
   public void setAddress(Address address).. 
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- // End code snippet

I want to use immediate = true, because the validation phase should not
occur (the name can be empty when searching an address). 
The problem is: this doesn't work! The page doesn't display the new set
values on address. I can change them directly in the component by using
component binding, but I think this isn't an elegant solution. Something
like context.setModelUpdated(true) would be nice. 
Maybe somebody has a simple solution for this problem? Many thanks in
advance.

Greetz, 


Dennie


Reply via email to