Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Unable to call Action Methof

 
narendran sivakumar
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have created a jsf page with several tables and input text boxes. I also have the command button to submit the values to the backing bean but, the action method "saveBean()" is not being called

Hear are the codes listed below listed

----------------------- JSF ---------------------
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
<%@ taglib uri="http://myfaces.apache.org/tomahawk" prefix="t"%>
<h:form id="myBioDataForm">
<h:panelGrid columns="2" >
<h:panelGroup >
<hutputLabel id="NameLabel" value="Name" style="font-size: medium"/>
</h:panelGroup>
<h:panelGroup >
<h:inputText id="NameTextBox" value="#{bioData.objBioDataVo.name}"/>
</h:panelGroup>

<h:panelGroup >
<hutputLabel id="DOBLabel" value="DOB" style="font-size: medium"/>
</h:panelGroup>
<h:panelGroup >
<t:inputCalendar id="DOBCalendar" renderAsPopup="true" value="#{bioData.objBioDataVo.doB}"/>
</h:panelGroup>

<h:panelGroup >
<hutputLabel id="AddressLabel" value="address" style="font-size: medium"/>
</h:panelGroup>
<h:panelGroup >
<hutputLabel value=""/>
</h:panelGroup>

<h:panelGroup >
<hutputLabel id="Street" value="Street" style="font-size: medium"/>
</h:panelGroup>
<h:panelGroup >
<h:inputText id="StreetTextBox" value="#{bioData.objBioDataVo.street}"/>
</h:panelGroup>

<h:panelGroup >
<hutputLabel id="City" value="Town/City" style="font-size: medium"/>
</h:panelGroup>
<h:panelGroup >
<h:inputText id="CityTextBox" value="#{bioData.objBioDataVo.city}"/>
</h:panelGroup>

<h:panelGroup >
<hutputLabel id="Pincode" value="Pincode" style="font-size: medium"/>
</h:panelGroup>
<h:panelGroup >
<h:inputText id="PincodeTextBox" value="#{bioData.objBioDataVo.pincode}"/>
</h:panelGroup>

<h:panelGroup >
<hutputLabel id="Mobile" value="Mobile" style="font-size: medium"/>
</h:panelGroup>
<h:panelGroup >
<h:inputText id="mobileTextBox" value="#{bioData.objBioDataVo.mobile}"/>
</h:panelGroup>

<h:panelGroup >
<hutputLabel id="Email" value="Email" style="font-size: medium"/>
</h:panelGroup>
<h:panelGroup >
<h:inputText id="emailTextBox" value="#{bioData.objBioDataVo.email}"/>
</h:panelGroup>

<h:panelGroup >
<hutputLabel id="Gender" value="Gender" style="font-size: medium"/>
</h:panelGroup>
<h:panelGroup >
<h:selectOneRadio value="#{bioData.objBioDataVo.gender}">
<f:selectItem itemLabel="Male" itemValue="Male"/>
<f:selectItem itemLabel="Female" itemValue="Female"/>
</h:selectOneRadio>
</h:panelGroup>

<h:panelGroup >
<hutputLabel id="Marital_Status" value="Marital Status" style="font-size: medium"/>
</h:panelGroup>
<h:panelGroup >
<h:selectOneRadio value="#{bioData.objBioDataVo.status}">
<f:selectItem itemLabel="Married" itemValue="Married"/>
<f:selectItem itemLabel="UnMarried" itemValue="UnMarried"/>
</h:selectOneRadio>
</h:panelGroup>
</h:panelGrid>
<f:verbatim><br><br><br></f:verbatim>

<h:dataTable var="item" value="#{bioData.al}">
<h:column>
<f:facet name="header" >
<hutputText value="No Of Years"/>
</f:facet>
<h:selectOneMenu id="NoYears1" value="#{item.noYears}">
<f:selectItems value="#{item.noYearsVoTM}"/>
</h:selectOneMenu>
</h:column>

<h:column>
<f:facet name="header" >
<hutputText value="Organisation"/>
</f:facet>
<h:inputText id="OrgnisationTextBox" value="#{item.orgVo}"/>
</h:column>

<h:column>
<f:facet name="header" >
<hutputText value="Designation"/>
</f:facet>
<h:inputText id="designationTextBox" value="#{item.desigVo}"/>
</h:column>

</h:dataTable>

<h:commandButton id="addRow" type="submit" value="Add Row" immediate="true" action="#{bioData.addStr}"/>


<h:dataTable var="edual" value="#{bioData.eduList}">
<h:column>
<f:facet name="header" >
<hutputText value="Year of Passing"/>
</f:facet>
<h:selectOneMenu id="NoYears11" value="#{edual.yearPassing}">
<f:selectItems value="#{edual.yearPassingTM}"/>
</h:selectOneMenu>
</h:column>

<h:column>
<f:facet name="header" >
<hutputText value="Qualification"/>
</f:facet>
<h:selectOneMenu id="NoYears11" value="#{edual.qualification}">
<f:selectItems value="#{edual.qualificationTM}"/>
</h:selectOneMenu>
</h:column>

<h:column>
<f:facet name="header" >
<hutputText value="Specialisation"/>
</f:facet>
<h:inputText id="SpecialisationTextBox1" value="#{edual.specialisation}"/>
</h:column>

<h:column>
<f:facet name="header" >
<hutputText value="Specialisation"/>
</f:facet>
<h:inputText id="SpecialisationTextBox1" value="#{edual.specialisation}"/>
</h:column>

<h:column>
<f:facet name="header" >
<hutputText value="School"/>
</f:facet>
<h:inputText id="SchoolTextBox1" value="#{edual.school}"/>
</h:column>

<h:column>
<f:facet name="header" >
<hutputText value="Total Marks"/>
</f:facet>
<h:inputText id="MarksTextBox1" value="#{edual.cgpa}"/>
</h:column>


</h:dataTable>

<h:commandButton id="addRow1" type="submit" value="AddRow" immediate="true" action="#{bioData.addEdu}"/>


<h:dataTable var="str" value="#{bioData.strList}">
<h:column>
<f:facet name="header" >
<hutputText value="sno"/>
</f:facet>
<h:inputText id="snoTextBox" value="#{str.sno}"/>
</h:column>

<h:column>
<f:facet name="header" >
<hutputText value="Stengths"/>
</f:facet>
<h:inputText id="StengthsTextBox" value="#{str.strengths}"/>
</h:column>

<h:column>
<f:facet name="header" >
<hutputText value="Weaknesses"/>
</f:facet>
<h:inputText id="WeaknessesTextBox" value="#{str.weaknesses}"/>
</h:column>

</h:dataTable>

<h:commandButton id="addRow2" type="submit" value="Add Row" immediate="true" action="#{bioData.addWks}"/>
<hutputLabel id = "saveLabel" value="Enter Name"/>
<h:inputText id="saveTextBox" value="#{bioData.bioName}"/>
<h:commandButton id="savebutton" type="submit" value="Save" action="#{bioData.saveBio}"/>
</h:form>

------------------------Backing Bean--------------------------------
package com.minerva.trainees;

import java.util.HashMap;

public class BioDataHomeBackingBean
{
String selectBio;
HashMap selectBioHM;
public BioDataHomeBackingBean() {
selectBioHM = new HashMap();
selectBioHM.put("Create BioData", "Create BioData");
}
public String processBioData()
{
String select_tmp = getSelectBio();
String action="";
if(select_tmp.equalsIgnoreCase("Create BioData"))
{
action= "displayCompetency@rgsRequest";
}
return action;
}
public String saveBio() throws Exception
{
System.out.println("########################Inside saveBio##################");
return "success";
}
public String getSelectBio() {
return selectBio;
}
public void setSelectBio(String selectBio) {
this.selectBio = selectBio;
}
public HashMap getSelectBioHM() {
return selectBioHM;
}
public void setSelectBioHM(HashMap selectBioHM) {
this.selectBioHM = selectBioHM;
}
}
-----------------------------faces config----------------------
<managed-bean>
<managed-bean-name>MyNameBB</managed-bean-name>
<managed-bean-class>com.minerva.trainees.MyNameBackingBean</managed-bean-class>
<managed-bean-scope>session</managed-bean-scope>
</managed-bean>
<managed-bean>
<managed-bean-name>bioData</managed-bean-name>
<managed-bean-class>com.minerva.trainees.BioDataBackingBean</managed-bean-class>
<managed-bean-scope>session</managed-bean-scope>
</managed-bean>
<managed-bean>
<managed-bean-name>bioDataHome</managed-bean-name>
<managed-bean-class>com.minerva.trainees.BioDataHomeBackingBean</managed-bean-class>
<managed-bean-scope>session</managed-bean-scope>
</managed-bean>
<managed-bean>
<managed-bean-name>bioTest</managed-bean-name>
<managed-bean-class>com.minerva.trainees.TestBean</managed-bean-class>
<managed-bean-scope>application</managed-bean-scope>
</managed-bean>
<managed-bean>
<managed-bean-name>objBioDataVo</managed-bean-name>
<managed-bean-class>com.minerva.trainees.BioDataVo</managed-bean-class>
<managed-bean-scope>session</managed-bean-scope>
</managed-bean>
 
Ketan Jambhekar
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi narendran,
You are calling the wrong managed bean from your action method.According to your mapping you should call bioDataHome.saveBio from your jsf page cause the saveBio method is present in the managedbean mapped with "bioDataHome".

Ketan.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic