This is one of the most used cases: On click of a link you need to enable/disable a button:
Something like shown above, following is the requirement:
1. On click of the link Click here the Go button should be enabled
2. Initially when the page is rendered the the Go button should be disabled
Lets see how to achieve this:
Create a bean having a boolean property which will be used to set the disabled property of the button Go. I have created a bean called TestBean with buttonDisable property
import javax.faces.event.ActionEvent;
import oracle.adf.view.rich.component.rich.nav.RichCommandButton;
import oracle.adf.view.rich.context.AdfFacesContext;
public class TestBean {
private boolean buttonDisable=true;
public void linkClicked(ActionEvent actionEvent) {
// Add event code here...
buttonDisable=false;
RichCommandButton button =(RichCommandButton)actionEvent.getComponent().findComponent("cb1");
AdfFacesContext.getCurrentInstance().addPartialTarget(button);
}
public void setButtonDisable(boolean buttonDisable) {
this.buttonDisable = buttonDisable;
}
public boolean isButtonDisable() {
return buttonDisable;
}
}
Setting this to true is going to make the Go button disabled when the page is loaded.
Then on wards if the link is clicked the linkClicked method is called which is going to set this boolean to false.
Happy Coding :)
This blog is really helpful.But, I have a query.Can you provide the code for adf page as well, I mean where to make changes in the jspx
ReplyDeletepage using adf keeping reference of the above code!!