Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

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!

how to disable html:text field in struts

843835Mar 4 2003 — edited Mar 4 2003

hi all,
I am using struts and have following jsp file.
1> I have several <html:text fields. If I want to disable a particular text field on some condition, how do i do that. Basically I want to make it non-editable.
e.g of text field is like
<td width="68%"> <html:text property="siteAddress1" maxlength="35" styleClass="inputtext"/> <img src="/swa/i/required.gif"> </td>

2>Also I have a country selection. It has a "onclick" method which calls a javascript function, that will populate the states dropdown in that selected country. My problem is if this jsp page is redirected to itself, then the country is still remain selected but the state remains empty.(reason the state javasript is not called again, since "onclick" is not the function called. How can i call the javascript again and get the states populated in dropdown, on the referesh of this jap page?

<%@ page language="java" %><%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %><%@ taglib uri="/WEB-INF/struts-form.tld" prefix="form" %><%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %><%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %><%@ taglib uri="http://jakarta.apache.org/taglibs/log-1.0" prefix="log" %> <%@ page import="java.util.*" %><%@ page import="com.cs.is.PSS.pim.data.PIMSite" %><%@ page import="com.cs.is.PSS.pim.struts.PIMSiteForm" %><%@ page import="com.cs.is.PSS.pim.struts.PIMEditLocationForm" %><%@ page import="com.cs.is.PSS.pim.util.PIMConstants" %><%@ page import="com.cs.is.PSS.common.*" %><script language="javascript"><%=Cache.getInstance().getStateListForJavascript()%>function loadStates(selectedState,stateFormName){    Country = editlocationForm.siteCountry.value;       var state1 = eval('editlocationForm.'+ stateFormName);       state1.length = 1;       if( Country == 'USA' || Country == 'CANADA' || Country =='AUSTRALIA' )       {         if (Country == 'AUSTRALIA')         {           currCountry = 1;         }         if (Country == 'CANADA')         {           currCountry = 2;         }         if (Country == 'USA')         {           currCountry = 3;                    }         var stateNames = states[currCountry].split(',');         state1.options[0].selected = true;         for (var i = 0; i < stateNames.length; i++)         {           var tempVar = stateNames<i>.split('|');           state1.options[i + 1] = new Option(tempVar[0], tempVar[1]);           if( selectedState == tempVar[1] )               state1.options[i + 1].selected = true;         }       }       else       {          state1.options[0] = new Option('No State', 'No State');          state1.options[0].selected = true;       }}</script><html:errors/><html:html locale="true"><head><link rel="stylesheet" href="../swa/c/cdc.css" type="text/css"><link rel="stylesheet" href="../swa/c/apps.css" type="text/css"></head><body><!-- Used for navigation of Tabs. Kiran  --><form  action="#" name="tabForm"> <html:hidden name="editlocationForm" property="beGeoId"/></form><!-- End  --><html:form action="/pim/addlocation.do" method="post"><html:hidden property="beGeoId"  /><!-- <html:hidden property="siteCountry" />   --><input type="hidden" name="mode" value="<%=PIMEditLocationForm.INSERT_MODE%>"/><table width="100%" border="0" cellspacing="0" cellpadding="0" >        <tr>           <td width="50%" align="left" valign="top" class="modulecontent"><bean:message key="PIMEditLocation.edit1"/><span class="modulecontentbold"><bean:message key="PIMEditLocation.edit2"/></span>            <bean:message key="PIMEditLocation.edit3"/></td>          <td width="50%" align="right" valign="top" class="modulecontent">RESPONSIVE DESIGNS INC (USA)</td>        </tr>      </table>      <span class="contenttitlealt"><bean:message key="PIMEditLocation.info"/></span>      <form name="editLocation">        <span class="content">         <table border="0" cellspacing="1" cellpadding="3" width="100%" class="content">          <tr bgcolor="#ffffff" valign="top" align="left" >             <td width="32%"  ><bean:message key="PIMEditLocation.LocationName"/></td>            <td width="68%"> <html:text property="siteName"  maxlength="45" styleClass="inputtext"/> <img src="/swa/i/required.gif"> </td>          </tr>          <tr bgcolor="#ffffff" valign="top" align="left" >             <td width="32%"  > <bean:message key="PIMEditLocation.address1"/></td>            <td width="68%"> <html:text property="siteAddress1"  maxlength="35" styleClass="inputtext"/> <img src="/swa/i/required.gif"> </td>          </tr>          <tr bgcolor="#ffffff" valign="top" align="left" >             <td width="32%" ><bean:message key="PIMEditLocation.address2"/></td>            <td width="68%"> <html:text property="siteAddress2"  maxlength="35"  styleClass="inputtext"/>  </td>            <td width="68%">&nbsp;</td>          </tr>          <tr bgcolor="#ffffff" valign="top" align="left" >             <td width="32%" ><bean:message key="PIMEditLocation.address3"/></td>           <td width="68%"> <html:text property="siteAddress3"  maxlength="35" styleClass="inputtext"/>  </td>            <td width="68%">&nbsp;</td>          </tr>          <tr bgcolor="#ffffff" valign="top" align="left" >             <td width="32%" ><bean:message key="PIMEditLocation.city"/></td>             <td width="68%"> <html:text property="siteCity"   maxlength="30" styleClass="inputtext"/> <img src="/swa/i/required.gif"> </td>          </tr> <!--         <tr bgcolor="#ffffff" valign="top" align="left" >            <td width="32%" ><bean:message key="PIMEditLocation.country"/></td>            <td width="68%"><bean:write name="editlocationForm" property="siteCountry"/></td>            <td width="68%">&nbsp;</td>          </tr>   -->          <tr bgcolor="#ffffff" valign="top" align="left" >          <td width="32%" ><bean:message key="PIMEditLocation.country"/></td>          <bean:define id="countryAllList" name="editlocationForm" property="countryAllList" type="java.util.ArrayList"/>          <td width="68%">          <html:select property="siteCountry" onclick="javascript:loadStates('', 'siteState');">          <html:options collection="countryAllList" property="id" labelProperty="label" />          </html:select>          </td>          </tr>                    <tr bgcolor="#ffffff" valign="top" align="left" >            <td width="32%" ><bean:message key="PIMEditLocation.state"/></td>            <td width="68%">              <html:select property="siteState">              <option value=""> <bean:message key="PIMEditLocation.state.select" /> </option>              </html:select>             <!-- <select name="select" >                <option value="0">Select One</option>                <option value="AL">ALABAMA</option>                <option value="CA" selected>CALIFORNIA</option>                <option value="MN">MINNESOTA</option>              </select> -->              <img src="/swa/i/required.gif">            </td>          </tr>          <tr bgcolor="#ffffff" valign="top" align="left" >             <td width="32%" ><bean:message key="PIMEditLocation.province"/><br>            </td>            <td width="68%">              <html:text styleClass="inputtext"  property="siteProvince"/>            </td>            <td width="68%">&nbsp;</td>          </tr>          <tr bgcolor="#ffffff" valign="top" align="left" >            <td width="32%" ><bean:message key="PIMEditLocation.postalcode"/> </td>            <td width="68%">               <html:text property="siteZip"   styleClass="inputtext"/> <img src="/swa/i/required.gif"> </td>            </td>          </tr>                    <tr bgcolor="#ffffff" valign="top" align="left" >             <td width="32%" ><bean:message key="PIMEditLocation.phone"/></td>            <td width="68%">               <html:text property="sitePhone"   maxlength="20" styleClass="inputtext"/> <img src="/swa/i/required.gif"> </td>            </td>          </tr>          <tr bgcolor="#ffffff" valign="top" align="left" >             <td width="32%" ><bean:message key="PIMEditLocation.fax"/></td>            <td width="68%">                <html:text styleClass="inputtext" maxlength="20" property="siteFax"/>            </td>            <td width="68%">&nbsp;</td>          </tr>          <tr bgcolor="#ffffff" valign="top" align="left" >            <td width="32%" ><bean:message key="PIMEditLocation.duns"/></td>            <td width="68%">              <html:text styleClass="inputtext" maxlength="256" property="siteDunsNo"/>            </td>            <td width="68%" ><a class="contentlink" href="https://www.dnb.com">Request               a DUNS Number</a> from Dun & Bradstreet. </td>          </tr>          <tr bgcolor="#ffffff" valign="top" align="left" >            <td width="32%" ><bean:message key="PIMEditLocation.locallang"/></td>            <td width="68%">             <html:select property="siteLocalLang" styleClass="modulecontent">              <bean:message key="PIMEditLocation.lang.select"/>              <html:options collection="languageList" property="id" labelProperty="label"/>             </html:select>            </td>          </tr>          <!--    <select name="localLang">                <option value="0" selected>Select One</option>                <option value="en">English</option>                <option value="fr">French</option>                <option value="ge">German</option>              </select>            </td>            <td width="68%">&nbsp;</td>          </tr>  -->                <!--    <tr bgcolor="#ffffff" valign="top" align="left" >            <td width="32%" ><bean:message key="PIMEditLocation.officetype"/></td>            <td width="68%">               <select name="OfficeType">                <option value="8" selected>Select One</option>                <option value="0">Sales Office</option>                <option value="1">Support Office</option>                <option value="2">Sales & Support Office</option>                <option value="3">Logistics Operations Office</option>                <option value="4">Manufacturing Site</option>                <option value="5">Training Office</option>                <option value="6">Company HQ</option>                <option value="7">Other</option>              </select>            </td>            <td width="68%">&nbsp;</td>          </tr>   -->          <tr bgcolor="#ffffff" valign="top" align="left" >          <td width="32%" ><bean:message key="PIMEditLocation.officetype"/></td>          <bean:define id="officeType" name="editlocationForm" property="officeType" type="java.util.ArrayList"/>          <td width="68%">          <html:select property="siteOfficeType" >          <html:options collection="officeType" property="id" labelProperty="label" />          </html:select>          </td>          </tr>          <tr bgcolor="#ffffff" valign="top" align="left" >            <td width="32%" ><bean:message key="PIMEditLocation.supportlocation"/></td>            <td width="68%">             <html:radio name="editlocationForm" property="siteIsSupportLoc" value="true" />               <bean:message key="PIMEditLocation.supportlocation.yes"/>             <html:radio name="editlocationForm" property="siteIsSupportLoc" value="false" />               <bean:message key="PIMEditLocation.supportlocation.No"/></td>            <td width="68%">&nbsp;</td>          </tr>                    <tr bgcolor="#ffffff" valign="top" align="left" >            <td width="32%" ><bean:message key="PIMEditLocation.headlocation"/></td>            <td width="68%">             <html:radio name="editlocationForm" property="siteIsHeadLoc" value="true" />               <bean:message key="PIMEditLocation.headlocation.yes"/>             <html:radio name="editlocationForm" property="siteIsHeadLoc" value="false" />               <bean:message key="PIMEditLocation.headlocation.No"/></td>            <td width="68%">&nbsp;</td>          </tr>        </table>        <br>        <input type="button" name="Back" value="<bean:message key="PIMEditLocation.back"/>" onClick="MM_callJS('history.back();')">        <input type="submit" name="Submit" value=<bean:message key="PIMEditLocation.submit"/>  />        </span> </html:form></body></html:html>
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 1 2003
Added on Mar 4 2003
3 comments
754 views