You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by John Holland <jh...@amcomsoft.com> on 2006/01/04 23:22:00 UTC

update other component values via an immediate action

Is it possible to update component values using an immediate action (no
validation)?

 

Here's the situation, I have a list of shifts that a user may select
from. When they select a shift and hit the load button it updates the
rest of the model with that shifts data.  The button is immediate
because I don't want any of the other data to be validated yet.  The
load button's code is below.

 

<h:commandButton type="submit"

                 value="#{msgs.loadButton}"

                 immediate="true"

     actionListener="#{onCallAssignmentBackerBean.loadShift}"

                 styleClass="button"/> 

 

 

The problem is that the new values don't seem to get displayed in the
resulting page the old ones are redisplayed instead.  Here's the
actionListener code I use to update my backing bean.

 

    /**

     * An immediate action, so I need to manually set the new shift.

     */

            public void loadShift(ActionEvent event) {

                        FacesContext context =
FacesContext.getCurrentInstance();

                        UIViewRoot viewRoot = context.getViewRoot();

                        

                        UIInput shiftComponent = (UIInput)
viewRoot.findComponent("mainForm:selectShiftBox");

                        

                        if(null != shiftComponent.getSubmittedValue()) {


                                   try {

                                               setSelectedShiftId(new
Long((String) shiftComponent.getSubmittedValue()));

                                   } catch (ClassCastException e) {

                                               //swallow it up... mmmm.
We don't want this error bubbling to the top.

                                   }

                        }

                        

            if(selectedShiftId != null) {

                        

                        ShiftBean shift =
onCallServices.getShift(selectedShiftId);

                        

                        setEndTime(shift.getEndDate());

                        setStartTime(shift.getStartDate());

                        setPriority(shift.getPriority());

                        setRemark(shift.getRemark());

                        

            }

    }

All of the other components values are drawn from this backing bean

 

The updates to the backing bean happen correctly and if you do a manual
refresh of the page the new values appear.   

 

It seems to me that the getters aren't being called for the other
components when the load button is activated.

 

Anybody have any idea what I'm doing wrong here?  Am I using the
immediate attribute correctly?

 

Thanks,

John

 


Re: update other component values via an immediate action

Posted by Simon Kitching <sk...@obsidium.com>.
John Holland wrote:
> Is it possible to update component values using an immediate action (no 
> validation)?
> 
>  
> 
> Here’s the situation, I have a list of shifts that a user may select 
> from. When they select a shift and hit the load button it updates the 
> rest of the model with that shifts data.  The button is immediate 
> because I don’t want any of the other data to be validated yet.  The 
> load button’s code is below.

[snip]

> 
> The problem is that the new values don’t seem to get displayed in the 
> resulting page the old ones are redisplayed instead.

See:
   http://wiki.apache.org/myfaces/ClearInputComponents

Regards,

Simon