You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Andrew Robinson <an...@gmail.com> on 2007/08/01 23:01:44 UTC

Re: ajax4jsf onchange event doesnt reRender Textfield

do you have any faces messages as a result of changing the menu
(conversion error, validation message, etc.)?

On 8/1/07, bansi <ma...@yahoo.com> wrote:
>
> When the page loads the textfield is disabled i.e. non-editable. It should be
> editable only thru onchange event of other component
> Here is the snippet
> <h:selectOneMenu id="assetMgmt" value="#{deviceBean.selectedAsset}"  >
>                                           <f:selectItem itemLabel="" itemValue="" />
>                                           <f:selectItems value="#{deviceBean.assetList}" />
>                                               <a4j:support  action="#{deviceBean.loadTagMode}"
> event="onchange"  reRender="propertyTag"/>
>                             </h:selectOneMenu>
>
> <a4j:outputPanel>
>                        <h:panelGrid columns="2" styleClass="detail"
> columnClasses="label" >
>
>                         <h:outputLabel><h:outputText  value="Property Tag" />
> </h:outputLabel>
>                             <h:inputText  id="propertyTag" value="#{deviceBean.tagNumber}"
> disabled="#{!updateDeviceBean.disableMode}">
>                                                         <a4j:support  action="#{deviceBean.loadAssetDetails}"
> event="onblur" reRender="mypanel"  />
>                              </h:inputText>
>
>                                         </h:panelGrid>
>                                 </a4j:outputPanel>
>
>
> Backing Bean
> public void loadTagMode() {
>           System.out.println("Inside loadTagDetails");
>                   disableMode = true;
>
> }
> Any pointers/suggestions will be highly appreciated
> --
> View this message in context: http://www.nabble.com/ajax4jsf-onchange--event-doesnt-reRender-Textfield-tf4202589.html#a11953535
> Sent from the MyFaces - Users mailing list archive at Nabble.com.
>
>

Re: ajax4jsf onchange event doesnt reRender Textfield

Posted by Andrew Robinson <an...@gmail.com>.
Is 'disabled="#{!updateDeviceBean.disableMode}"' set anywhere outside
of loadAssetDetials?

If that control is disabled on decode, it will never update.

Try simplifying your code to only the bare minimum functionality (use
a test page with a test bean for example). Then keep adding back
functionality until it fails. This way you will know exactly what is
wrong.

Using rendered, disabled and readOnly attributes that tie to backing
bean methods is very tricky and should be avoided when possible. The
reason is the JSF lifecycle. As you should know, the process is
Decode/Validate/Update/Action

Since the actions are not fired until the end, you cannot rely on
changes to rendered/disabled/readOnly until the render phase, not the
decode.

Try this:

<a4j:form>
<a4j:outputPanel ajaxRendered="true">
<t:messages globalOnly="false" />
</a4j:outputPanel>
<a4j:region>
<h:inputText value="#{bean.searchText}" />
<a4j:commandLink reRender="result" value="Search"
  actionListener="#{bean.onSearch} />
</a4j:region>
<a4j:outputPanel id="result">
<h:outputText value="#{bean.searchText}" />
</a4j:outputPanel>
</a4j:form>

@Name("bean") @Scope(ScopeType.SESSION)
public class MyBean {
private String searchText;
public String getSearchText() { return this.searchText; }
public void setSearchText(String searchText) { this.searchText = searchText; }
public void onSearch(ActionEvent evt) {
  // TODO
}

Use this, make sure it is working, and start adding back in your functionality.

On 8/2/07, bansi <ma...@yahoo.com> wrote:
>
> I have <a4j:outputPanel />  & <a4j:region /> in my code and it works fine
> first time i.e. if user has not entered anything into the textfield then
> onblur event functions as desirable i.e. clears off other fields on the form
> with the help of backing bean method . The problem is when i go back to the
> textfield and key in the value it still holds the null value
>
> Here is the snippet
> <h:inputText  id="propertyTag" value="#{updateDeviceBean.tagNumber}"
> disabled="#{!updateDeviceBean.disableMode}">
>                                                 <a4j:support  action="#{updateDeviceBean.loadAssetDetails}"
> event="onblur" reRender="mypanel" />
>
>                                         </h:inputText>
>
> <a4j:outputPanel  id="mypanel">
> ....
> </a4j:outputPanel  >
>
> Backing Bean method
>  public String loadAssetDetails() {
> if (!StringUtils.isEmpty(tagNumber) && !StringUtils.isEmpty(selectedAsset)){
>                                   System.out.println("In not null");
> }
> else if(StringUtils.isEmpty(tagNumber)){
>                                   System.out.println("In tagNo null");
>  disableMode = false;
>                                   return null;
>                           }
>                           else{
>                                   System.out.println("In else");
>                                   disableMode = false;
>                                   return null;
>                           }
> }
>
>
> Andrew Robinson-5 wrote:
> >
> > Once again, check to see if there are validation errors. I recommend
> > always using a4j:regions around data that is submit by AJAX. This way
> > you know exactly which components are being submitted/decoded/updated.
> >
> > Also, at least when debugging, make sure there is the following in every
> > page:
> >
> > <a4j:outputPanel ajaxRendered="true">
> > <t:messages globalOnly="false" />
> > </a4j:outputPanel>
> >
> > -Andrew
> >
> > On 8/2/07, bansi <ma...@yahoo.com> wrote:
> >>
> >> Good question Andrew. I knew you are pointing at Conversion or
> >> Validations
> >> which may occur during onchange event. It was error in my code which i
> >> fixed
> >> it & works fine now
> >>
> >> But i am having another wierd problem
> >> I have onblur event on textfield which functions as expected in case the
> >> textfield has null value. But if i go back & key in the value for
> >> textfield
> >> it still holds the null value & doesnt recognizes the new keyed in value
> >> .
> >> from debugging statement i figured out the setXXX() method doesn't get
> >> called
> >>
> >>
> >>
> >>
> >>
> >> Andrew Robinson-5 wrote:
> >> >
> >> > do you have any faces messages as a result of changing the menu
> >> > (conversion error, validation message, etc.)?
> >> >
> >> > On 8/1/07, bansi <ma...@yahoo.com> wrote:
> >> >>
> >> >> When the page loads the textfield is disabled i.e. non-editable. It
> >> >> should be
> >> >> editable only thru onchange event of other component
> >> >> Here is the snippet
> >> >> <h:selectOneMenu id="assetMgmt" value="#{deviceBean.selectedAsset}"  >
> >> >>                                           <f:selectItem itemLabel=""
> >> >> itemValue="" />
> >> >>                                           <f:selectItems
> >> >> value="#{deviceBean.assetList}" />
> >> >>                                               <a4j:support
> >> >> action="#{deviceBean.loadTagMode}"
> >> >> event="onchange"  reRender="propertyTag"/>
> >> >>                             </h:selectOneMenu>
> >> >>
> >> >> <a4j:outputPanel>
> >> >>                        <h:panelGrid columns="2" styleClass="detail"
> >> >> columnClasses="label" >
> >> >>
> >> >>                         <h:outputLabel><h:outputText  value="Property
> >> >> Tag" />
> >> >> </h:outputLabel>
> >> >>                             <h:inputText  id="propertyTag"
> >> >> value="#{deviceBean.tagNumber}"
> >> >> disabled="#{!updateDeviceBean.disableMode}">
> >> >>                                                         <a4j:support
> >> >> action="#{deviceBean.loadAssetDetails}"
> >> >> event="onblur" reRender="mypanel"  />
> >> >>                              </h:inputText>
> >> >>
> >> >>                                         </h:panelGrid>
> >> >>                                 </a4j:outputPanel>
> >> >>
> >> >>
> >> >> Backing Bean
> >> >> public void loadTagMode() {
> >> >>           System.out.println("Inside loadTagDetails");
> >> >>                   disableMode = true;
> >> >>
> >> >> }
> >> >> Any pointers/suggestions will be highly appreciated
> >> >> --
> >> >> View this message in context:
> >> >>
> >> http://www.nabble.com/ajax4jsf-onchange--event-doesnt-reRender-Textfield-tf4202589.html#a11953535
> >> >> Sent from the MyFaces - Users mailing list archive at Nabble.com.
> >> >>
> >> >>
> >> >
> >> >
> >>
> >> --
> >> View this message in context:
> >> http://www.nabble.com/ajax4jsf-onchange--event-doesnt-reRender-Textfield-tf4202589.html#a11971431
> >> Sent from the MyFaces - Users mailing list archive at Nabble.com.
> >>
> >>
> >
> >
>
> --
> View this message in context: http://www.nabble.com/ajax4jsf-onchange--event-doesnt-reRender-Textfield-tf4202589.html#a11972227
> Sent from the MyFaces - Users mailing list archive at Nabble.com.
>
>

Re: ajax4jsf onchange event doesnt reRender Textfield

Posted by bansi <ma...@yahoo.com>.
I have <a4j:outputPanel />  & <a4j:region /> in my code and it works fine
first time i.e. if user has not entered anything into the textfield then
onblur event functions as desirable i.e. clears off other fields on the form
with the help of backing bean method . The problem is when i go back to the
textfield and key in the value it still holds the null value 

Here is the snippet
<h:inputText  id="propertyTag" value="#{updateDeviceBean.tagNumber}"
disabled="#{!updateDeviceBean.disableMode}">
						<a4j:support  action="#{updateDeviceBean.loadAssetDetails}"
event="onblur" reRender="mypanel" />
						
					</h:inputText>

<a4j:outputPanel  id="mypanel">	
....
</a4j:outputPanel  >	

Backing Bean method
 public String loadAssetDetails() {
if (!StringUtils.isEmpty(tagNumber) && !StringUtils.isEmpty(selectedAsset)){ 
				  System.out.println("In not null");
}
else if(StringUtils.isEmpty(tagNumber)){
				  System.out.println("In tagNo null");
 disableMode = false;
				  return null;
			  }
			  else{
				  System.out.println("In else");
				  disableMode = false;
				  return null;
			  }
}


Andrew Robinson-5 wrote:
> 
> Once again, check to see if there are validation errors. I recommend
> always using a4j:regions around data that is submit by AJAX. This way
> you know exactly which components are being submitted/decoded/updated.
> 
> Also, at least when debugging, make sure there is the following in every
> page:
> 
> <a4j:outputPanel ajaxRendered="true">
> <t:messages globalOnly="false" />
> </a4j:outputPanel>
> 
> -Andrew
> 
> On 8/2/07, bansi <ma...@yahoo.com> wrote:
>>
>> Good question Andrew. I knew you are pointing at Conversion or
>> Validations
>> which may occur during onchange event. It was error in my code which i
>> fixed
>> it & works fine now
>>
>> But i am having another wierd problem
>> I have onblur event on textfield which functions as expected in case the
>> textfield has null value. But if i go back & key in the value for
>> textfield
>> it still holds the null value & doesnt recognizes the new keyed in value
>> .
>> from debugging statement i figured out the setXXX() method doesn't get
>> called
>>
>>
>>
>>
>>
>> Andrew Robinson-5 wrote:
>> >
>> > do you have any faces messages as a result of changing the menu
>> > (conversion error, validation message, etc.)?
>> >
>> > On 8/1/07, bansi <ma...@yahoo.com> wrote:
>> >>
>> >> When the page loads the textfield is disabled i.e. non-editable. It
>> >> should be
>> >> editable only thru onchange event of other component
>> >> Here is the snippet
>> >> <h:selectOneMenu id="assetMgmt" value="#{deviceBean.selectedAsset}"  >
>> >>                                           <f:selectItem itemLabel=""
>> >> itemValue="" />
>> >>                                           <f:selectItems
>> >> value="#{deviceBean.assetList}" />
>> >>                                               <a4j:support
>> >> action="#{deviceBean.loadTagMode}"
>> >> event="onchange"  reRender="propertyTag"/>
>> >>                             </h:selectOneMenu>
>> >>
>> >> <a4j:outputPanel>
>> >>                        <h:panelGrid columns="2" styleClass="detail"
>> >> columnClasses="label" >
>> >>
>> >>                         <h:outputLabel><h:outputText  value="Property
>> >> Tag" />
>> >> </h:outputLabel>
>> >>                             <h:inputText  id="propertyTag"
>> >> value="#{deviceBean.tagNumber}"
>> >> disabled="#{!updateDeviceBean.disableMode}">
>> >>                                                         <a4j:support
>> >> action="#{deviceBean.loadAssetDetails}"
>> >> event="onblur" reRender="mypanel"  />
>> >>                              </h:inputText>
>> >>
>> >>                                         </h:panelGrid>
>> >>                                 </a4j:outputPanel>
>> >>
>> >>
>> >> Backing Bean
>> >> public void loadTagMode() {
>> >>           System.out.println("Inside loadTagDetails");
>> >>                   disableMode = true;
>> >>
>> >> }
>> >> Any pointers/suggestions will be highly appreciated
>> >> --
>> >> View this message in context:
>> >>
>> http://www.nabble.com/ajax4jsf-onchange--event-doesnt-reRender-Textfield-tf4202589.html#a11953535
>> >> Sent from the MyFaces - Users mailing list archive at Nabble.com.
>> >>
>> >>
>> >
>> >
>>
>> --
>> View this message in context:
>> http://www.nabble.com/ajax4jsf-onchange--event-doesnt-reRender-Textfield-tf4202589.html#a11971431
>> Sent from the MyFaces - Users mailing list archive at Nabble.com.
>>
>>
> 
> 

-- 
View this message in context: http://www.nabble.com/ajax4jsf-onchange--event-doesnt-reRender-Textfield-tf4202589.html#a11972227
Sent from the MyFaces - Users mailing list archive at Nabble.com.


Re: ajax4jsf onchange event doesnt reRender Textfield

Posted by Andrew Robinson <an...@gmail.com>.
Once again, check to see if there are validation errors. I recommend
always using a4j:regions around data that is submit by AJAX. This way
you know exactly which components are being submitted/decoded/updated.

Also, at least when debugging, make sure there is the following in every page:

<a4j:outputPanel ajaxRendered="true">
<t:messages globalOnly="false" />
</a4j:outputPanel>

-Andrew

On 8/2/07, bansi <ma...@yahoo.com> wrote:
>
> Good question Andrew. I knew you are pointing at Conversion or Validations
> which may occur during onchange event. It was error in my code which i fixed
> it & works fine now
>
> But i am having another wierd problem
> I have onblur event on textfield which functions as expected in case the
> textfield has null value. But if i go back & key in the value for textfield
> it still holds the null value & doesnt recognizes the new keyed in value .
> from debugging statement i figured out the setXXX() method doesn't get
> called
>
>
>
>
>
> Andrew Robinson-5 wrote:
> >
> > do you have any faces messages as a result of changing the menu
> > (conversion error, validation message, etc.)?
> >
> > On 8/1/07, bansi <ma...@yahoo.com> wrote:
> >>
> >> When the page loads the textfield is disabled i.e. non-editable. It
> >> should be
> >> editable only thru onchange event of other component
> >> Here is the snippet
> >> <h:selectOneMenu id="assetMgmt" value="#{deviceBean.selectedAsset}"  >
> >>                                           <f:selectItem itemLabel=""
> >> itemValue="" />
> >>                                           <f:selectItems
> >> value="#{deviceBean.assetList}" />
> >>                                               <a4j:support
> >> action="#{deviceBean.loadTagMode}"
> >> event="onchange"  reRender="propertyTag"/>
> >>                             </h:selectOneMenu>
> >>
> >> <a4j:outputPanel>
> >>                        <h:panelGrid columns="2" styleClass="detail"
> >> columnClasses="label" >
> >>
> >>                         <h:outputLabel><h:outputText  value="Property
> >> Tag" />
> >> </h:outputLabel>
> >>                             <h:inputText  id="propertyTag"
> >> value="#{deviceBean.tagNumber}"
> >> disabled="#{!updateDeviceBean.disableMode}">
> >>                                                         <a4j:support
> >> action="#{deviceBean.loadAssetDetails}"
> >> event="onblur" reRender="mypanel"  />
> >>                              </h:inputText>
> >>
> >>                                         </h:panelGrid>
> >>                                 </a4j:outputPanel>
> >>
> >>
> >> Backing Bean
> >> public void loadTagMode() {
> >>           System.out.println("Inside loadTagDetails");
> >>                   disableMode = true;
> >>
> >> }
> >> Any pointers/suggestions will be highly appreciated
> >> --
> >> View this message in context:
> >> http://www.nabble.com/ajax4jsf-onchange--event-doesnt-reRender-Textfield-tf4202589.html#a11953535
> >> Sent from the MyFaces - Users mailing list archive at Nabble.com.
> >>
> >>
> >
> >
>
> --
> View this message in context: http://www.nabble.com/ajax4jsf-onchange--event-doesnt-reRender-Textfield-tf4202589.html#a11971431
> Sent from the MyFaces - Users mailing list archive at Nabble.com.
>
>

Re: ajax4jsf onchange event doesnt reRender Textfield

Posted by bansi <ma...@yahoo.com>.
Good question Andrew. I knew you are pointing at Conversion or Validations
which may occur during onchange event. It was error in my code which i fixed
it & works fine now

But i am having another wierd problem
I have onblur event on textfield which functions as expected in case the
textfield has null value. But if i go back & key in the value for textfield
it still holds the null value & doesnt recognizes the new keyed in value .
from debugging statement i figured out the setXXX() method doesn't get
called





Andrew Robinson-5 wrote:
> 
> do you have any faces messages as a result of changing the menu
> (conversion error, validation message, etc.)?
> 
> On 8/1/07, bansi <ma...@yahoo.com> wrote:
>>
>> When the page loads the textfield is disabled i.e. non-editable. It
>> should be
>> editable only thru onchange event of other component
>> Here is the snippet
>> <h:selectOneMenu id="assetMgmt" value="#{deviceBean.selectedAsset}"  >
>>                                           <f:selectItem itemLabel=""
>> itemValue="" />
>>                                           <f:selectItems
>> value="#{deviceBean.assetList}" />
>>                                               <a4j:support 
>> action="#{deviceBean.loadTagMode}"
>> event="onchange"  reRender="propertyTag"/>
>>                             </h:selectOneMenu>
>>
>> <a4j:outputPanel>
>>                        <h:panelGrid columns="2" styleClass="detail"
>> columnClasses="label" >
>>
>>                         <h:outputLabel><h:outputText  value="Property
>> Tag" />
>> </h:outputLabel>
>>                             <h:inputText  id="propertyTag"
>> value="#{deviceBean.tagNumber}"
>> disabled="#{!updateDeviceBean.disableMode}">
>>                                                         <a4j:support 
>> action="#{deviceBean.loadAssetDetails}"
>> event="onblur" reRender="mypanel"  />
>>                              </h:inputText>
>>
>>                                         </h:panelGrid>
>>                                 </a4j:outputPanel>
>>
>>
>> Backing Bean
>> public void loadTagMode() {
>>           System.out.println("Inside loadTagDetails");
>>                   disableMode = true;
>>
>> }
>> Any pointers/suggestions will be highly appreciated
>> --
>> View this message in context:
>> http://www.nabble.com/ajax4jsf-onchange--event-doesnt-reRender-Textfield-tf4202589.html#a11953535
>> Sent from the MyFaces - Users mailing list archive at Nabble.com.
>>
>>
> 
> 

-- 
View this message in context: http://www.nabble.com/ajax4jsf-onchange--event-doesnt-reRender-Textfield-tf4202589.html#a11971431
Sent from the MyFaces - Users mailing list archive at Nabble.com.