hi all, i am using jsf and using the ibm ajax components in the same. i have 2 buttons on the screens. i have identifying the buttons with the help of the javascript and using the hidden fields to give values to them. when i first click the button i am getting the proper values in the constructor in getFacesContext().getExternalContext().getRequestParameterMap().get("somevalue"); when i click the other button at that time also i am getting proper values, but again when i click the first button i am not getting the value as required and as set in the js. i have to do all this bcoz we are using odc:tabbedPanel in the page and my jsp is included in the same and i dont want to submit my page. thus using ajax. please provide a solution for the same. my jps code and constructor code is as below:
<%-- tpl:metadata --%>
<%-- jsf:pagecode language="java" location="/src/pagecode/view/assignee/EmergencyContacts.java" --%><%-- /jsf:pagecode --%>
<%-- /tpl:metadata --%><%@taglib uri="http://java.sun.com/jsf/core"
prefix="f"%><%@taglib uri="http://java.sun.com/portlet_2_0"
prefix="portlet"%>
<%@taglib uri="http://giams.com/jsf/GIAMSCustomJSF" prefix="giams"%><%@taglib
uri="http://www.ibm.com/xmlns/prod/websphere/portal/v6.1/portlet-client-model"
prefix="portlet-client-model"%><%@taglib
uri="http://www.ibm.com/jsf/html_extended" prefix="hx"%><%@taglib
uri="http://java.sun.com/jsf/html" prefix="h"%><%@page language="java"
contentType="text/html" pageEncoding="UTF-8" session="false"%><portlet-client-model:init>
<portlet-client-model:require module="ibm.portal.xml.*" />
<portlet-client-model:require module="ibm.portal.portlet.*" />
</portlet-client-model:init>
<portlet:defineObjects />
<link rel="stylesheet" type="text/css" title="Style"
href='<%=renderResponse.encodeURL(renderRequest.getContextPath()
+ "/theme/stylesheet.css")%>'>
<f:loadBundle var="giamsBundle"
basename="com.ibm.assignmentinitrequestportlet.nl.GIAMSResourceBundle" />
<script language="JavaScript"
src='<%=renderResponse.encodeURL(renderRequest.getContextPath()
+ "/js/common.js")%>'>
</script>
<script>
function myfunctionEmer(myobj){
var formIndex;
for(var i=0;i<document.forms.length;i++){
var tempRowId=document.forms[i].id;
var tempForm=tempRowId.split(':');
if(tempForm.length>1){
if(tempForm[1]=="form1"){
formIndex=i;
}
}
}
//alert(myobj.id);
document.getElementById(document.forms[formIndex].id+':subview5:inputRowVal').value = myobj.id;
}
function viewClicked(viewBtn)
{
var formIndex;
for(var i=0;i<document.forms.length;i++){
var tempRowId=document.forms[i].id;
var tempForm=tempRowId.split(':');
if(tempForm.length>1){
if(tempForm[1]=="form1"){
formIndex=i;
}
}
}
//alert(viewBtn.id);
document.getElementById(document.forms[formIndex].id+':subview5:saveBtnEmer').value = null;
document.getElementById(document.forms[formIndex].id+':subview5:viewBtnEmer').value = "viewBtnEmer";
}
function saveClicked(saveBtn)
{
var formIndex;
for(var i=0;i<document.forms.length;i++){
var tempRowId=document.forms[i].id;
var tempForm=tempRowId.split(':');
if(tempForm.length>1){
if(tempForm[1]=="form1"){
formIndex=i;
}
}
}
//alert(saveBtn.id);
document.getElementById(document.forms[formIndex].id+':subview5:viewBtnEmer').value=null;
document.getElementById(document.forms[formIndex].id+':subview5:saveBtnEmer').value = "saveBtnEmer";
}
</script>
<h:inputHidden id="inputRowVal" />
<h:inputHidden id="viewBtnEmer" />
<h:inputHidden id="saveBtnEmer" />
<h:panelGrid columns="1" cellpadding="1" border="0" width="100%">
<h:outputText id="titleContactInfoEmer" styleClass="outputText"
value="#{giamsBundle['title.emergency.contacts']}" escape="false"></h:outputText>
<h:messages style="font-weight:bold;color:red;" layout="table"></h:messages>
<h:outputText styleClass="outputText" id="msgMandatoryEmer"
value="#{giamsBundle['msg.fields.mandatory']}" />
<h:outputText value="<br/>" escape="false" />
<h:outputText value="<br/>" escape="false" />
<h:outputText styleClass="outputText" id="msgContactsEmer"
value="#{giamsBundle['msg.contacts']}" />
<h:outputText value="<br/>" escape="false" />
<h:outputText value="<br/>" escape="false" />
<h:messages style="font-weight:bold;color:red;" layout="table"></h:messages>
<h:outputText style="font-weight:bold;color:red;"
rendered="#{pc_EmergencyContacts.showNoRecordError}"
value="#{giamsBundle['err.select.record']}" escape="false" />
<h:outputText value="<br/>" escape="false" />
<h:outputText value="<br/>" escape="false" />
<h:panelGroup id="tableExEmer">
<hx:dataTableEx border="0" cellpadding="2" cellspacing="2"
columnClasses="columnClass1" headerClass="headerClass"
footerClass="footerClass" rowClasses="rowClass1, rowClass2"
styleClass="dataTableEx" id="dtContacts"
value="#{business_air_assignee.emergencyContactList}" var="contact"
width="100%">
<hx:columnEx>
<f:facet name="header">
</f:facet>
<hx:inputRowSelect styleClass="inputRowSelect" id="rowSelect1Emer"
onclick="myfunctionEmer(this)" selectOne="true"
value="#{contact.selected}"></hx:inputRowSelect>
</hx:columnEx>
<hx:columnEx>
<f:facet name="header">
<h:outputText value="#{giamsBundle['lbl.loc']}" />
</f:facet>
<h:outputText id="loc" value="#{contact.location}"></h:outputText>
<h:inputHidden id="location" value="#{contact.location}" />
</hx:columnEx>
<hx:columnEx>
<f:facet name="header">
<h:outputText value="#{giamsBundle['lbl.type']}" />
</f:facet>
<h:outputText value="Primary" rendered="#{contact.contactType}" />
<h:outputText value="Secondary"
rendered="#{!contact.contactType && contact.contactType!=null}" />
<h:outputText value="-" rendered="#{contact.contactType==null}" />
</hx:columnEx>
<hx:columnEx>
<f:facet name="header">
<h:outputText value="#{giamsBundle['title.relationship']}" />
</f:facet>
<h:outputText value="#{contact.relationShip}" />
<h:outputText value="-" rendered="#{contact.relationShip==null}" />
</hx:columnEx>
<hx:columnEx>
<f:facet name="header">
<h:outputText value="#{giamsBundle['lbl.contact.name']}" />
</f:facet>
<h:outputText value="#{contact.firstName} "
escape="false" />
<h:outputText value="#{contact.lastName}" />
<h:outputText value="-" rendered="#{contact.firstName==null}" />
</hx:columnEx>
<hx:columnEx>
<f:facet name="header">
<h:outputText value="#{giamsBundle['title.mobile.phone']}" />
</f:facet>
<hx:dataTableEx border="0" cellpadding="0" cellspacing="0"
columnClasses="columnClass1" headerClass="headerClass"
footerClass="footerClass" rowClasses="rowClass1, rowClass2"
styleClass="dataTableEx" id="dtTele"
value="#{contact.telephoneAddressList}" var="tele" width="100%">
<hx:columnEx>
<h:outputText value="#{tele.telephoneNumber}"
rendered="#{tele.telephoneTypeCode=='CELL'}"></h:outputText>
</hx:columnEx>
</hx:dataTableEx>
</hx:columnEx>
</hx:dataTableEx>
</h:panelGroup>
<hx:ajaxRefreshRequest target="tableExEmer" id="ajaxRefreshRequest2Emer" ></hx:ajaxRefreshRequest>
<h:outputText value="<br/>" escape="false" />
<h:outputText value="<br/>" escape="false" />
<h:panelGrid columns="1" cellpadding="1" border="0" width="100%">
<h:column>
<h:panelGroup>
<hx:commandExButton type="button" onclick="viewClicked(this)"
value="#{giamsBundle['btn.view.edit']}" styleClass="commandExButton"
id="btnViewEditEmer" action="#{pc_EmergencyContacts.doViewEditAction}"
tabindex="1">
<hx:behavior event="onclick" id="behavior1EmerView" behaviorAction="get"
targetAction="ViewSectionEmer"></hx:behavior>
</hx:commandExButton>
</h:panelGroup>
</h:column>
</h:panelGrid>
<h:outputText value="<br/>" escape="false" />
<h:outputText value="<br/>" escape="false" />
<h:panelGroup id="ViewSectionEmer">
<hx:panelSection styleClass="panelSection"
rendered="#{pc_EmergencyContacts.showForm}"
id="pSectionContactDetails" initClosed="false"
style="border-width: thin; border-style: groove">
<hx:panelFormBox helpPosition="over" labelPosition="left"
styleClass="panelFormBox" id="formBox1Emer">
<hx:formItem styleClass="formItem" id="frmItemAccType"
label=" #{giamsBundle['lbl.contact.type']}"
escape="false" showHelp="none">
<giams:referenceDataSelectOneMenu
styleClass="referenceDataSelectOneMenu"
id="ddContactType" refdataCode="CONTACT_TYPE"
value="#{pc_EmergencyContacts.contactDetail.contactType}">
</giams:referenceDataSelectOneMenu>
</hx:formItem>
<hx:formItem styleClass="formItem" id="frmItemRelationship"
label=" #{giamsBundle['lbl.dependents.relationship.colon']}"
escape="false" showHelp="none">
<giams:referenceDataSelectOneMenu
styleClass="referenceDataSelectOneMenu"
id="ddContactRelation" refdataCode="DEPENDENT_RELATION"
value="#{pc_EmergencyContacts.contactDetail.relationShip}">
</giams:referenceDataSelectOneMenu>
</hx:formItem>
<hx:formItem styleClass="formItem" id="frmItemName"
label=" #{giamsBundle['lbl.name']}" escape="false"
showHelp="none">
<h:inputText styleClass="inputText" id="txtFirstName"
maxlength="40" required="true" tabindex="4"
value="#{pc_EmergencyContacts.contactDetail.firstName}">
<hx:validateConstraint regex="#{pc_Formatter.nameFormat}" />
</h:inputText>
</hx:formItem>
<hx:formItem styleClass="formItem" id="frmItemPhone"
label=" #{giamsBundle['lbl.phone.number']}"
escape="false" showHelp="none">
<h:inputText styleClass="inputText" id="txtPhoneNumber"
required="true" tabindex="5"
value="#{pc_EmergencyContacts.phoneNumber}">
<hx:validateConstraint regex="#{pc_Formatter.numericOnlyFormat }" />
</h:inputText>
</hx:formItem>
<hx:formItem styleClass="formItem" id="frmItemMobilePhone"
label=" #{giamsBundle['lbl.mobile.phone.colon']}"
escape="false" showHelp="none">
<h:inputText styleClass="inputText" id="txtMobilePhone"
tabindex="6" value="#{pc_EmergencyContacts.mobileNumber}">
<hx:validateConstraint regex="#{pc_Formatter.numericOnlyFormat }" />
</h:inputText>
</hx:formItem>
<hx:formItem styleClass="formItem" id="frmItemEmailAdd"
label=" #{giamsBundle['lbl.email.colon']}"
escape="false" showHelp="none">
<h:inputText styleClass="inputText" id="txtEmailAddress"
maxlength="50" tabindex="7"
value="#{pc_EmergencyContacts.contactDetail.currentEmailAddress.emailAddress}">
<hx:validateConstraint regex="#{pc_Formatter.emailFormat}" />
</h:inputText>
</hx:formItem>
<hx:formItem styleClass="formItem" id="frmItemAddLine1"
label=" #{giamsBundle['lbl.address.line1.emercontacts']}"
escape="false" showHelp="none">
<h:inputText styleClass="inputText" id="txtAddressLine1"
maxlength="40" tabindex="8"
value="#{pc_EmergencyContacts.contactDetail.contactAddress.addressLine1}"></h:inputText>
</hx:formItem>
<hx:formItem styleClass="formItem" id="frmItemAddLine2"
label=" #{giamsBundle['lbl.address.line2']}"
escape="false" showHelp="none">
<h:inputText styleClass="inputText" id="txtAddressLine2"
maxlength="40" tabindex="9"
value="#{pc_EmergencyContacts.contactDetail.contactAddress.addressLine2}"></h:inputText>
</hx:formItem>
<hx:formItem styleClass="formItem" id="frmItemAddLine3"
label=" #{giamsBundle['lbl.address.line3']}"
escape="false" showHelp="none">
<h:inputText styleClass="inputText" id="txtAddressLine3"
maxlength="40" tabindex="10"
value="#{pc_EmergencyContacts.contactDetail.contactAddress.addressLine3}"></h:inputText>
</hx:formItem>
<hx:formItem styleClass="formItem" id="frmItemCity"
label=" #{giamsBundle['lbl.city.emercontacts']}"
escape="false" showHelp="none">
<h:inputText styleClass="inputText" id="txtCity" maxlength="40"
tabindex="11"
value="#{pc_EmergencyContacts.contactDetail.contactAddress.cityName}"></h:inputText>
</hx:formItem>
<hx:formItem styleClass="formItem" id="frmItemStateProvince"
label=" #{giamsBundle['lbl.state.province.dep']}"
escape="false" showHelp="none">
<h:selectOneMenu styleClass="selectOneMenu" id="ddStateProvince"
tabindex="12"
value="#{pc_EmergencyContacts.contactDetail.contactAddress.stateCode}">
<f:selectItems value="#{pc_referenceData.stateProvinceList}" />
</h:selectOneMenu>
</hx:formItem>
<hx:formItem styleClass="formItem" id="frmItemCountry"
label=" #{giamsBundle['lbl.country.emercontacts']}"
escape="false" showHelp="none">
<giams:referenceDataSelectOneMenu
styleClass="referenceDataSelectOneMenu"
id="ddCountry" refdataCode="COUNTRY"
value="#{pc_EmergencyContacts.contactDetail.contactAddress.countryCode}">
</giams:referenceDataSelectOneMenu>
</hx:formItem>
<hx:formItem styleClass="formItem" id="frmItemZipCode"
label=" #{giamsBundle['lbl.zip.postal.code.emercontacts']}"
escape="false" showHelp="none">
<h:inputText styleClass="inputText" id="txtZipPostalCode"
tabindex="14"
value="#{pc_EmergencyContacts.contactDetail.contactAddress.postalCode}">
<hx:validateConstraint regex="#{pc_Formatter.zipFormat}" />
</h:inputText>
</hx:formItem>
<hx:formItem styleClass="formItem" id="frmItemComments"
label=" #{giamsBundle['lbl.comments']}"
escape="false" showHelp="none">
<h:inputTextarea styleClass="inputTextarea" id="txtarComments"
tabindex="15"
value="#{pc_EmergencyContacts.contactDetail.comments}" />
</hx:formItem>
</hx:panelFormBox>
<f:facet name="closed">
<hx:jspPanel id="jspPanel21">
<hx:graphicImageEx id="imageEx21" styleClass="graphicImageEx"
align="middle" value="/theme/img/menu_bar.GIF" width="100%"
height="10"></hx:graphicImageEx>
<hx:graphicImageEx id="imageExClosed2" styleClass="graphicImageEx"
align="middle" value="/theme/img/icon-link-expand-dark.gif"></hx:graphicImageEx>
<h:outputText id="text5" styleClass="outputText"
value="#{giamsBundle['lbl.contact.details']}"></h:outputText>
</hx:jspPanel>
</f:facet>
<f:facet name="opened">
<hx:jspPanel id="jspPanel22">
<hx:graphicImageEx id="imageEx22" styleClass="graphicImageEx"
align="middle" value="/theme/img/menu_bar.GIF" width="100%"
height="10"></hx:graphicImageEx>
<hx:graphicImageEx id="imageExOpen2" styleClass="graphicImageEx"
align="middle" value="/theme/img/icon-list-close.gif"></hx:graphicImageEx>
<h:outputText id="text6" styleClass="outputText"
value="#{giamsBundle['lbl.contact.details']}"></h:outputText>
</hx:jspPanel>
</f:facet>
</hx:panelSection>
</h:panelGroup>
<hx:ajaxRefreshRequest id="ajaxRefreshRequest1Emer" target="ViewSectionEmer"
params="viewBtnEmer;saveBtnEmer;inputRowVal;txtFirstName;txtCity;ddContactType;ddContactRelation;txtPhoneNumber;txtMobilePhone;txtEmailAddress;txtAddressLine1;txtAddressLine2;txtAddressLine3;ddStateProvince;ddCountry;txtZipPostalCode;txtarComments"></hx:ajaxRefreshRequest>
<h:outputText value="<br/>" escape="false" />
<h:panelGroup id="saveBtnPnlGrpEmer">
<hx:commandExButton type="button" value="#{giamsBundle['btn.save']}"
styleClass="commandExButton" id="btnSaveEmer" onclick="saveClicked(this)"
action="#{pc_EmergencyContacts.doSaveAction}" tabindex="16">
<hx:behavior event="onclick" id="behaviorEmerSave" behaviorAction="get;get"
targetAction="ViewSectionEmer;tableExEmer"></hx:behavior>
</hx:commandExButton>
</h:panelGroup>
</h:panelGrid>
constuctor snippet:
String viewBtnValue = (String) getFacesContext().getExternalContext().getRequestParameterMap().get("viewBtnEmer");
if (viewBtnValue!=null && viewBtnValue.equals("viewBtnEmer")) {
doViewEditAction(row);
}
String saveBtnValue = (String) getFacesContext().getExternalContext().getRequestParameterMap().get("saveBtnEmer");
if (saveBtnValue!=null && saveBtnValue.equals("saveBtnEmer")) {
doSaveAction(row);
}