I'm trying to make a checkbox that when clicked, should copy the mailing address string from the service address string.
I was hoping I could simply set the value of the mailing address to the service address in the checkbox's valueChangeListener.
But when the checkbox is checked, the mailing address doesn't get updated.
Also, I noticed that I can't get the value of the service address the first time the checkbox is checked, but it does give me the value on subsequent checkbox clicks.
These are the relevant parts of my xhtml and bean
form.xhtml
Code:
<ice:form id="myForm">
<ice:selectBooleanCheckbox id="copyMailingAddressFromOwner" required="false"
valueChangeListener="#{newService.handleCopyMailingAddress}"
value="#{newService.copyMailingAddressFromServiceAddress}" autocomplete="off" />
mailing address: <ice:inputText id="mailingAddress" value="#{newService.mailingAddress}"/>
<br/>
service address: <ice:inputText id="serviceAddress" value="#{newService.serviceAddress}"/>
</ice:form>
bean newServiceAction.java:
Code:
@Stateful
@Name("newService")
@Scope(CONVERSATION)
public class NewServiceAction implements NewService {
public String getMailingAddress() {
return mailingAddress;
}
public void setMailingAddress(String mailingAddress) {
this.mailingAddress=mailingAddress;
}
public String getServiceAddress() {
return serviceAddress;
}
public void setServiceAddress(String serviceAddress) {
this.serviceAddress =serviceAddress;
}
public void handleCopyMailingAddress(ValueChangeEvent e) {
if (!this.copyMailingAddressFromOwner)
{
this.setServiceAddress(this.getMailingAddress());
}
else
{
this.setServiceAddress("");
}
}
FYI, I'm using Icefaces 1.7.0 with Seam 2.0.1.GA
Also note that I have gotten this to work using what seems to be like a hack, when I put this code in the valueChangeListener for the checkbox:
Code:
UIViewRoot viewRoot=javax.faces.context.FacesContext.getCurrentInstance().getViewRoot();
UIInput input = (UIInput) viewRoot.findComponent("myForm:serviceAddress");
input.setValue(newService.mailingAddress);
But obviously I'd like to avoid this since it requires using client-ids.
Any help would be greatly appreciated.
Thanks,
dave