This week's book giveaway is in the OCAJP forum.
We're giving away four copies of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) and have Khalid A Mughal & Rolf W Rasmussen on-line!
See this thread for details.
Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JSF + AJAX + RichFaces

 
Mahendra Chowdary
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi , I am facing a error while trying to implement ajax functionality in my JSF page .

Please look into my code and help me out

My Jsf Page :



My Java Code Looks like this :



When i try to launch my application ,

before performing any action

one of the methods getFirstRadioChecked is being executed .

Why is it so ..

Why other methods are not executed .

But when i perform any action like selecting the first radio button , the method is not being called .

Please suggest how i can fix this .

Thanks
 
Ilari Moilanen
Ranch Hand
Posts: 199
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
To answer your first question the getFirstRadioChecked is called because of this
rendered="#{addContact.firstRadioChecked}"

The getter will naturally have to be called to determine the value.

The other getters are not being called since you do not define the properties anywhere and you do not use them in rendered attributes either. For example you do not call the getter for secondRadioChecked anywhere in your code.

I do not know the syntax for a:support but are you sure that the action should look like this
action="#{addContact.firstRadioChecked}"

Normally (everywhere else where the action attribute is present) the action points to a method not a property. But I guess you have read the documentation and know what you are doing. I am (still) not familiar with richfaces taglibrary but I am beginning to think that it is a good thing

But maybe someone who has more experience with richfaces can help you more. At least you should add the term richfaces to your subject line since JSF does not equal richfaces
 
Mahendra Chowdary
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
To answer your first question the getFirstRadioChecked is called because of this
rendered="#{addContact.firstRadioChecked}"

The getter will naturally have to be called to determine the value.

Thanks for this Info But my intention is to get the true or false value after performing an action

So how can i achieve it now , i cant give rendered = "true/false" i need to determine whether it is true or false based on whether the button is selected or not


The other getters are not being called since you do not define the properties anywhere and you do not use them in rendered attributes either. For example you do not call the getter for secondRadioChecked anywhere in your code.

I do not know the syntax for a:support but are you sure that the action should look like this
action="#{addContact.firstRadioChecked}"

Yes it is in the same syntax

Normally (everywhere else where the action attribute is present) the action points to a method not a property. But I guess you have read the documentation and know what you are doing. I am (still) not familiar with richfaces taglibrary but I am beginning to think that it is a good thing

But maybe someone who has more experience with richfaces can help you more. At least you should add the term richfaces to your subject line since JSF does not equal richfaces

Will do that for sure

Mostly here we are not using much of the rich faces tag libs here
So i think the problem is not with the rich faces
 
Ilari Moilanen
Ranch Hand
Posts: 199
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Go Green wrote:
Mostly here we are not using much of the rich faces tag libs here
So i think the problem is not with the rich faces[/color]
Oh? I tought that the "a" in your code implied RichFaces ajax tags Ajax4Jsf. If they do not then it was my mistake. Is the "a" then some JSF 1 specific tag?

There is a "support" tag in richfaces taglibraries as well
http://docs.jboss.org/richfaces/latest_3_3_X/en/tlddoc/a4j/support.html
that has a action attribute that is supposed to point to a method, not a property.

And here is the full taglib
http://docs.jboss.org/richfaces/latest_3_3_X/en/tlddoc/

But I of course do not know what version of richfaces you are using or do you even use JSF 1 or JSF 2.

In any case in your code you have two a:support tags that are inside your f:selectItem tags. Maybe there should be only one a:support that is inside h:selectOneRadio? But I do not know.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic