Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Setter Methods are not being called

 
Surendra Poranki
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Folks

I have a customer search page in which they can search for ,regular customers,Business Customers or Govt Customers. When I search for Some regular customer the setter methods are called but when i search for business and govt customer the setter methods are not being called.
We use the tomhawk faces.

<%@ taglib uri="http://myfaces.apache.org/tomahawk" prefix="t"%>

facesConfig

<managed-bean>
<managed-bean-name>customerSearchBean</managed-bean-name>
<managed-bean class>us.tn.state.trust.presentation.beans.CustomerSearchBean</managed-bean-class>
<managed-bean-scope>request</managed-bean-scope>

Here is my jsp Page

<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td>
<table>
<tr>
<td colspan="2">
<h:panelGroup>
<h:message for="indvFrstNme" errorClass="error"></h:message>
<h:message for="busNme" errorClass="error"></h:message>
<h:message for="govtNme" errorClass="error"></h:message>
</h:panelGroup>
</td>
<td colspan="2">
<h:panelGroup>
<h:message for="indvMidNme" errorClass="error"></h:message>
<h:message for="busFein" errorClass="error"></h:message>
<h:message for="govtLvlCde" errorClass="error"></h:message>
</h:panelGroup>
</td>
</tr>
<tr>
<td>
<hutputText value="#{messages.customerSearch_indvFrstNme}" styleClass="labelTextBlackBold" rendered="#{customerSearchBean.isIndividual}"></hutputText>
<hutputText value="#{messages.customerSearch_busNme}" styleClass="labelTextBlackBold" rendered="#{customerSearchBean.isBusiness}"></hutputText>
<hutputText value="#{messages.customerSearch_govtNme}" styleClass="labelTextBlackBold" rendered="#{customerSearchBean.isGovernment}"></hutputText>
</td>
<td>
<h:inputText id="indvFrstNme" size="10" maxlength="25" value="#{customerSearchBean.indvFrstNme}" rendered="#{customerSearchBean.isIndividual}">
<t:validateRegExpr pattern="[a-zA-Z0-9]+"></t:validateRegExpr>
</h:inputText>
<h:inputText id="busNme" size="10" maxlength="60" value="#{customerSearchBean.busNme}" rendered="#{customerSearchBean.isBusiness}">
<t:validateRegExpr pattern="[a-zA-Z0-9]+" ></t:validateRegExpr>
</h:inputText>
<h:inputText id="govtNme" size="10" maxlength="60" value="#{customerSearchBean.govtNme}" rendered="#{customerSearchBean.isGovernment}">
<t:validateRegExpr pattern="[a-zA-Z0-9]+"></t:validateRegExpr>
</h:inputText>
</td>
<td>
<hutputText value="#{messages.customerSearch_indvMidNme}" styleClass="labelTextBlackBold" rendered="#{customerSearchBean.isIndividual}"></hutputText>
<hutputText value="#{messages.customerSearch_busFein}" styleClass="labelTextBlackBold" rendered="#{customerSearchBean.isBusiness}"></hutputText>
<hutputText value="#{messages.customerSearch_govtLvlCde}" styleClass="labelTextBlackBold" rendered="#{customerSearchBean.isGovernment}"></hutputText>
</td>
<td>
<h:inputText id="indvMidNme" size="10" maxlength="25" value="#{customerSearchBean.indvMidNme}" rendered="#{customerSearchBean.isIndividual}">
<t:validateRegExpr pattern="[a-zA-Z0-9]+" ></t:validateRegExpr>
</h:inputText>
<h:inputText id="busFein" size="10" maxlength="9" value="#{customerSearchBean.busFein}" rendered="#{customerSearchBean.isBusiness}">
<t:validateRegExpr pattern="[a-zA-Z0-9]+"></t:validateRegExpr>
</h:inputText>
<h:selectOneMenu id="levelCode" value="#{customerSearchBean.govtLvlCde}" rendered="#{customerSearchBean.isGovernment}" styleClass="labelTextBlack">
<f:selectItems value="#{customerSearchBean.levelCodeList}"/>
<a4j:support event="onchange" action="#{customerSearchBean.changeGovernmentLevel}" ></a4j:support>
</h:selectOneMenu>
</td>
</tr>
<tr>
<td colspan="2">
<h:message for="indvLastNme" errorClass="error"></h:message>
</td>
<td colspan="2">
<h:message for="indvNmeSfx" errorClass="error"></h:message>
</td>
</tr>
<tr>
<td>
<hutputText value="#{messages.customerSearch_indvLastNme}" styleClass="labelTextBlackBold" rendered="#{customerSearchBean.isIndividual}"></hutputText>
</td>
<td>
<h:inputText id="indvLastNme" size="10" maxlength="40" value="#{customerSearchBean.indvLastNme}" rendered="#{customerSearchBean.isIndividual}">
<t:validateRegExpr pattern="[a-zA-Z0-9]+"></t:validateRegExpr>
</h:inputText>
</td>
<td>
<hutputText value="#{messages.customerSearch_indvNmeSfx}" styleClass="labelTextBlackBold" rendered="#{customerSearchBean.isIndividual}"></hutputText>
</td>
<td>
<h:inputText id="indvNmeSfx" size="10" maxlength="3" value="#{customerSearchBean.indvNmeSfx}" rendered="#{customerSearchBean.isIndividual}"></h:inputText>
</td>
</tr>
<tr>
<td colspan="2">
<h:panelGroup>
<h:message for="indvDrvrLicNbr" errorClass="error"></h:message>
<h:message for="busLicNbr" errorClass="error"></h:message>
</h:panelGroup>
</td>
<td colspan="2">
<h:panelGroup>
<h:message for="drvrLicStCde" errorClass="error"></h:message>
<h:message for="busSaleTaxNbr" errorClass="error"></h:message>
</h:panelGroup>
</td>
</tr>
<tr>
<td>
<hutputText value="#{messages.customerSearch_indvDrvrLicNbr}" styleClass="labelTextBlackBold" rendered="#{customerSearchBean.isIndividual}"></hutputText>
<hutputText value="#{messages.customerSearch_busLicNbr}" styleClass="labelTextBlackBold" rendered="#{customerSearchBean.isBusiness}"></hutputText>
</td>
<td>
<h:inputText id="indvDrvrLicNbr" size="10" maxlength="25" value="#{customerSearchBean.indvDrvrLicNbr}" rendered="#{customerSearchBean.isIndividual}">
<t:validateRegExpr pattern="[a-zA-Z0-9]+"></t:validateRegExpr>
</h:inputText>
<h:inputText id="busLicNbr" size="10" maxlength="12" value="#{customerSearchBean.busLicNbr}" rendered="#{customerSearchBean.isBusiness}">
<t:validateRegExpr pattern="[a-zA-Z0-9]+"></t:validateRegExpr>
</h:inputText>
</td>
<td>
<hutputText value="#{messages.customerSearch_drvrLicStCde}" styleClass="labelTextBlackBold" rendered="#{customerSearchBean.isIndividual}"></hutputText>
<hutputText value="#{messages.customerSearch_busSaleTaxNbr}" styleClass="labelTextBlackBold" rendered="#{customerSearchBean.isBusiness}"></hutputText>
</td>
<td>
<h:selectOneMenu id="drvrLicStCde" value="#{customerSearchBean.drvrLicStCde}" rendered="#{customerSearchBean.isIndividual}" styleClass="labelTextBlack">
<f:selectItems value="#{statesBean.stateList}" />
</h:selectOneMenu>
<h:inputText id="busSaleTaxNbr" size="10" maxlength="12" value="#{customerSearchBean.busSaleTaxNbr}" rendered="#{customerSearchBean.isBusiness}">
<t:validateRegExpr pattern="[a-zA-Z0-9]+"></t:validateRegExpr>
</h:inputText>
</td>
</tr>
</table>
</td>
</tr>
</table>
 
Tushar Kherde
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

According to the JSF lifecycle if there is an error at validation phase or conversion phase, then setter wont get called.
 
Surendra Poranki
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is there a way to debug these kind of issues its really hard to find if theres some thing wrong with the JSF page.
 
Benson Fung
Ranch Hand
Posts: 219
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Surendra,

Please let me know if you got the solution. I am also being stuck to the similar problem that you came across.


thanks
Benson
 
suresh dasari
Ranch Hand
Posts: 121
Chrome Eclipse IDE Mac
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Guys,

I am also facing the same problem, I am not seeing any problem in JSF page, but setter is not calling.
if one found solution please let me know.
 
Tim Holloway
Saloon Keeper
Pie
Posts: 18277
56
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Surendra, your example is very hard to read. The JavaRanch message editor has a button labelled "Code" that can be used to generate wrapper tags. If you use that, it won't chew up things.

A useful trick in JSF to debug validation problems is to put an "h:messages" tag up at the top of the view so that all the generated messages will display. Make sure you have the "globalonly" attribute set to false, so that the per-field messages display as well as the general messages.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic