开发者

How can I check for gender value by NameID?

I have this code that checks duplicate name id

NameRefBean myNameBean = new NameRefBean();
myNameBean.load(NameID);
if (!myNameBean.getErrFlag()) {
    errExistFlag = true;
    errCode = DUPLICATE_NAME_ID;
    return(false);

I have switch case where it saves data from the jsp page form

case ACTION_SAVE:
    if (hdTxnType.equalsIgnoreCase("Add")) {
       if (validateInputData()) {
        nameBean.setNameID(tbNameID);
        nameBean.setName(tbName);
                    nameBean.setGender(tbGender);
        hdTxnType = new String("Update");
                }
            } else {
                nameBean.setNameID(hdNameID);
                nameBean.setName(tbName);
                nameBean.setGender(tbGender);

            }
            break;

My question is how can I check for gender value when particular nameid is selected? If user changes gender value from M to F, I need to give a warning on the jsp page saying "gender already exist do you want to modify it?"

Here is my jsp page

<% if (nameBean.getErrFlag()) {%>
    <CENTER><b><font color=red><%= nameBean.getErrMsg() %></b></font></CENTER>
<% } %>

<TABLE WIDTH="800" BORDER="0">

  <TR>
    <TD><B>Name ID: </B></TD>
<% if (nameBean.getTxnType().equalsIgnoreCase("Add"))
   { %>
    <TD><INPUT TYPE=TEXT NAME="tbNameID" VALUE="<%= nameBean.getnameID()%>" ></TD>
<% } else { %>
    <TD><%= nameBean.getNameID()%> </TD>
<% } %>

    <TD><B> Name: </B></TD>
    <TD><INPUT TYPE=TEXT NAME="tbName" VALUE="<%= nameBean.getName()%>" ></TD>

    <TD><B>Gender: </B></TD>
    <TD><INPUT TYPE=TEXT NAME="tbGender" VALUE="<%= nameBean.getGender()%>"  ></TD>
  </TR>

<BR>

  <TR>
<%  if (userProfileBean.hasRole("FULL") ) { %>
    <TD>
    <INPUT TYPE=SUBMIT NAME="action" VALUE="Save Changes">&nbsp;
<% if (nameBean.getTxnType().equalsIgnoreCase("Update"))
   { %>
    <INPUT TYPE=SUBMIT NAME="action" VALUE="Delete">&nbsp;
<% } %>
    <INPUT TYPE=SUBMIT NAME="action" VALUE="Cancel"开发者_JAVA百科>&nbsp;
    </TD>
<% } %>


You could add a piece of JavaScript that print the warning, if a user changed the gender. The only thing you have to do then, is to enable this java script if the nameid is already set (then the name already exists, and every change should print the warning.) If the nameid is null, then it is a new name and you must not enable the java script warning functionality.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜