You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Guy Bashan <gu...@gmail.com> on 2008/08/18 17:10:54 UTC

[MyFaces][Core] Immediate problem

Hi,

 

I have another problem with "immediate":

It seems like the hidden field always shows value="true" no matter what I am
doing.

The UI functionality is good. I have a link the shows: active/inactive.

But hidden field value always stays the same.

 

I have the same posted code:

          <h:inputHidden id="active" value="#{accountUser.active}" />

          <h:commandLink value="#{accountUser.active == 'true' ?
bundle['account_user.status.inactivate'] :
bundle['account_user.status.activate']}"
action="#{accountUser.setStatusActive}" immediate="true"
styleClass="linkor">

            <f:param name="active" value="#{accountUser.active}" />

          </h:commandLink>

 

My action code is:

  public void setStatusActive()

  {

    setActive((!Boolean.valueOf(FacesUtil.getRequestParameter("active"))) +
"");

    FacesUtil.renderResponse();

  }

 

Thanks,

Guy.      

 

 


RE: [MyFaces][Core] Immediate problem

Posted by Guy Bashan <gu...@gmail.com>.
Doesn't it matter that I update the model "manually" in my action?
I thought by updating it "manually" it should reflect on the resulted
response...

Thanks,
Guy.

-----Original Message-----
From: Simon Kitching [mailto:skitching@apache.org] 
Sent: Monday, August 18, 2008 6:47 PM
To: MyFaces Discussion
Subject: Re: [MyFaces][Core] Immediate problem

Guy Bashan schrieb:
>
> Hi,
>
>  
>
> I have another problem with "immediate":
>
> It seems like the hidden field always shows value="true" no matter 
> what I am doing.
>
> The UI functionality is good. I have a link the shows: active/inactive.
>
> But hidden field value always stays the same.
>
>  
>
> I have the same posted code:
>
>           <h:inputHidden id="active" value="#{accountUser.active}" />
>
>           <h:commandLink value="#{accountUser.active == 'true' ? 
> bundle['account_user.status.inactivate'] : 
> bundle['account_user.status.activate']}" 
> action="#{accountUser.setStatusActive}" immediate="true" 
> styleClass="linkor">
>
>             <f:param name="active" value="#{accountUser.active}" />
>
>           </h:commandLink>
>
>  
>
> My action code is:
>
>   public void setStatusActive()
>
>   {
>
>     
> setActive((!Boolean.valueOf(FacesUtil.getRequestParameter("active"))) 
> + "");
>
>     FacesUtil.renderResponse();
>
>   }
>

That's standard behaviour for immediate. You should read this page:
  http://wiki.apache.org/myfaces/How_The_Immediate_Attribute_Works

Because the command is immediate and you do renderResponse(), there is 
no updateModel phase. And therefore all input fields just hold their 
submittedValue internally and re-render that instead of pushing their 
value to the model then reading back from the model.

As that wiki page says, "immediate" is really meant for "cancel-button" 
type behaviour. Using it for any other purpose is a "hack", and can be 
rather tricky. Sometimes it is necessary (JSF appears to be a bit 
limited in this area) but you need to be careful. If you want different 
parts of the page to effectively have different lifecycles, then perhaps 
AJAX is what you really need...

Regards, Simon


RE: [MyFaces][Core] Immediate problem

Posted by Guy Bashan <gu...@gmail.com>.
Hi Simon,
Thanks for your suggestion, I took the approach of the AJAX. This way I can
take off the "immediate" and the value is being applied properly.

Thanks,
Guy.


-----Original Message-----
From: Simon Kitching [mailto:skitching@apache.org] 
Sent: Monday, August 18, 2008 6:47 PM
To: MyFaces Discussion
Subject: Re: [MyFaces][Core] Immediate problem

Guy Bashan schrieb:
>
> Hi,
>
>  
>
> I have another problem with "immediate":
>
> It seems like the hidden field always shows value="true" no matter 
> what I am doing.
>
> The UI functionality is good. I have a link the shows: active/inactive.
>
> But hidden field value always stays the same.
>
>  
>
> I have the same posted code:
>
>           <h:inputHidden id="active" value="#{accountUser.active}" />
>
>           <h:commandLink value="#{accountUser.active == 'true' ? 
> bundle['account_user.status.inactivate'] : 
> bundle['account_user.status.activate']}" 
> action="#{accountUser.setStatusActive}" immediate="true" 
> styleClass="linkor">
>
>             <f:param name="active" value="#{accountUser.active}" />
>
>           </h:commandLink>
>
>  
>
> My action code is:
>
>   public void setStatusActive()
>
>   {
>
>     
> setActive((!Boolean.valueOf(FacesUtil.getRequestParameter("active"))) 
> + "");
>
>     FacesUtil.renderResponse();
>
>   }
>

That's standard behaviour for immediate. You should read this page:
  http://wiki.apache.org/myfaces/How_The_Immediate_Attribute_Works

Because the command is immediate and you do renderResponse(), there is 
no updateModel phase. And therefore all input fields just hold their 
submittedValue internally and re-render that instead of pushing their 
value to the model then reading back from the model.

As that wiki page says, "immediate" is really meant for "cancel-button" 
type behaviour. Using it for any other purpose is a "hack", and can be 
rather tricky. Sometimes it is necessary (JSF appears to be a bit 
limited in this area) but you need to be careful. If you want different 
parts of the page to effectively have different lifecycles, then perhaps 
AJAX is what you really need...

Regards, Simon


Re: [MyFaces][Core] Immediate problem

Posted by Simon Kitching <sk...@apache.org>.
Guy Bashan schrieb:
>
> Hi,
>
>  
>
> I have another problem with "immediate":
>
> It seems like the hidden field always shows value="true" no matter 
> what I am doing.
>
> The UI functionality is good. I have a link the shows: active/inactive.
>
> But hidden field value always stays the same.
>
>  
>
> I have the same posted code:
>
>           <h:inputHidden id="active" value="#{accountUser.active}" />
>
>           <h:commandLink value="#{accountUser.active == 'true' ? 
> bundle['account_user.status.inactivate'] : 
> bundle['account_user.status.activate']}" 
> action="#{accountUser.setStatusActive}" immediate="true" 
> styleClass="linkor">
>
>             <f:param name="active" value="#{accountUser.active}" />
>
>           </h:commandLink>
>
>  
>
> My action code is:
>
>   public void setStatusActive()
>
>   {
>
>     
> setActive((!Boolean.valueOf(FacesUtil.getRequestParameter("active"))) 
> + "");
>
>     FacesUtil.renderResponse();
>
>   }
>

That's standard behaviour for immediate. You should read this page:
  http://wiki.apache.org/myfaces/How_The_Immediate_Attribute_Works

Because the command is immediate and you do renderResponse(), there is 
no updateModel phase. And therefore all input fields just hold their 
submittedValue internally and re-render that instead of pushing their 
value to the model then reading back from the model.

As that wiki page says, "immediate" is really meant for "cancel-button" 
type behaviour. Using it for any other purpose is a "hack", and can be 
rather tricky. Sometimes it is necessary (JSF appears to be a bit 
limited in this area) but you need to be careful. If you want different 
parts of the page to effectively have different lifecycles, then perhaps 
AJAX is what you really need...

Regards, Simon