Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

Help: JSF and a4j

843844Jun 20 2008 — edited Jun 23 2008
Hi,

I am pretty new on JSF and Ajax and wonder if someone could help me to resolve this problem:
- I have 2 text boxes (Email Address and CC Address) and one check box (CC). When the checkbox is checked, it should copy the value from text box 1 to text box 2. Just simple like that. Here is how I did it:

<rich:inplaceInput value="#{emailBean.toAddresses}" id="toAddress" inputWidth="350" minInputWidth="350" required="true"/>
<rich:inplaceInput value="#{emailBean.ccAddresses}" id="ccAddress" inputWidth="350" minInputWidth="350"/>

<h:selectBooleanCheckbox id="ccMeCheckbox" valueChangeListener="#{emailReportBean.ccMe}">
<a4j:support event="onclick" reRender="ccAddress"/>
</h:selectBooleanCheckbox>

In the backingBean, here is what I did:
public void setCcAddresses(String ccAddresses) {
if (ccMe == Boolean.TRUE){
this.ccAddresses = this.fromAddress;
} else {
this.ccAddresses = ccAddresses;
}
}

But it is not working :(. Could someone help and tell me if I am missing anything. Thank you!

Comments

843844
Hi Timmya ,
I think your problem is that the jsf value change event is handled before update-model phase so the previous selected values are re-setted after the ccMe method. If so take a look to this old topic: valueChangeListener

Do you really need a server call to copy a value from an input text to another?
843844
It was cut and paste. I actually use value="#{emailBean.ccMe}" instead of value Change listener.
I saw the value has changed in the emailBean but the server call is called first (a4j: support) before it sets the value of emailBean.ccMe.
How can I avoid that? I want to set the value of ccMe first before the a4j call to check if the checkbox is selected.
I don't need a server call to copy value.
Thanks!
843844
You can write a simlpy client side javascript function to copy the value of an input text to the other one, than call the function attaching a javascript event (onchange, onclick) to the checkbox. You don't need a4j:support or valueChangeEvent to accomplish the task.
843844
Thank you!
1 - 4
Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on Jul 21 2008
Added on Jun 20 2008
4 comments
221 views