Skip to Main Content

Java Development Tools

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!

commandbutton action event/action listener not working

shreevatApr 22 2013 — edited May 19 2013
All,

I am trying to invoke a action listener event on a command button in JSF but it is not working. I have the command button insider a panelformlayout within panelgroup. There have been no error messages in any of the page sources. I have tried all possible options like adding action listener to the managed bean, method binding etc but no luck. Is there any restriction in adding action listener to the command button?

Managed bean code and page source below.

--Managed bean

package xx.demo;

import java.sql.CallableStatement;

import javax.faces.event.ActionEvent;

import oracle.adf.view.rich.component.rich.input.RichInputText;
import oracle.adf.view.rich.component.rich.input.RichSelectOneChoice;

import oracle.jbo.ApplicationModule;
import oracle.jbo.server.ApplicationModuleImpl;
import oracle.jbo.server.DBTransaction;

public class LeaveActions {
private RichSelectOneChoice choLeaveType;

public void setLeaveType(RichSelectOneChoice choLeaveType) {
this.choLeaveType = choLeaveType;

}

public RichSelectOneChoice getLeaveType() {
return choLeaveType;
}

public String onApplyButtonClick() {
// Add event code here...
System.out.println("Inside onApplyButtonClick " );
try{
String strLeaveType=getLeaveType().getValue().toString();
System.out.println("Leave type value is " + strLeaveType);
}
catch(Exception e){
System.out.println("Leave type value is " + e.toString());
}
return "success";
}


public void ApplyButtonClicked(ActionEvent e){
// Call the same method to do something
String strMsg = "testing";

}


}

---Page source

<?xml version='1.0' encoding='UTF-8'?>
<jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="2.1" xmlns:f="http://java.sun.com/jsf/core"
xmlns:af="http://xmlns.oracle.com/adf/faces/rich" xmlns:h="http://java.sun.com/jsf/html">
<jsp:directive.page contentType="text/html;charset=UTF-8"/>
<f:view>
<af:document title="System" id="d1">
<af:messages id="m1"/>
<af:form id="f1">
<af:panelStretchLayout id="psl1" startWidth="160px">
<f:facet name="top">
<af:panelGroupLayout id="pgl1" layout="vertical" halign="center">
<af:panelFormLayout id="pfl1" rows="1" maxColumns="1">
<af:outputText value="System" id="ot1"
inlineStyle="color:Blue; font-family:'Times New Roman', 'Arial Black', times, Serif; font-size:175%; font-weight:bold; text-align:center;"/>
</af:panelFormLayout>
</af:panelGroupLayout>

</f:facet>
<f:facet name="bottom">
<af:panelGroupLayout id="pgl2"/>
</f:facet>
<f:facet name="center">
<af:panelGroupLayout layout="scroll" id="pgl4">
<af:outputText value="Dashboard" id="ot6"
inlineStyle="color:Green; font-size:150%; font-family:'Times New Roman', 'Arial Black', times, Serif; font-weight:bold; text-align:center;"
rendered='true'/>
<af:panelFormLayout id="pfl2" rows="1" maxColumns="1"
rendered='true"}'>
</af:panelFormLayout>
<af:panelStretchLayout id="psl2" bottomHeight="51px">
<f:facet name="bottom">
<af:panelGroupLayout id="pgl6"/>
</f:facet>
<f:facet name="center">
<af:panelGroupLayout id="pgl5" halign="center" layout="vertical">
<af:panelFormLayout id="pfl6" rows="1" maxColumns="2"
rendered='true'>
<af:commandButton text="Apply" id="cb1"
partialSubmit="false"
blocking="true"
immediate="false"
action="#{jsfBean.onApplyButtonClick}"
actionListener="#{jsfBean.ApplyButtonClicked}"/>
<af:commandButton text="Cancel" id="cb2"
inlineStyle="font-family:'Times New Roman', 'Arial Black', times, Serif;"/>
</af:panelFormLayout>
</af:panelGroupLayout>
</f:facet>
<f:facet name="top">
<af:panelGroupLayout id="pgl7"/>
</f:facet>
</af:panelStretchLayout>
</af:panelGroupLayout>
</f:facet>
<f:facet name="start">
<af:panelGroupLayout id="pgl3" halign="left">
<p>
<af:outputText value="Welcome!" id="otWel"
inlineStyle="color:Maroon;"/>
</p>
<af:spacer width="1" height="50" id="s2"/>
</af:panelGroupLayout>
</f:facet>
</af:panelStretchLayout>
</af:form>
</af:document>
</f:view>
</jsp:root>


Thanks in advance.

Thanks
Shree
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jun 16 2013
Added on Apr 22 2013
22 comments
12,877 views