Dear Rich, I had my javascript validation break the page like that when I had two conditions incorrect in my page:
1) I put my <html:javascript formName="something"/> tag within my opening/closing <html:form></html:/form> tags 2) when I used #1 with the wrong formName="something" (i.e. no matching validation formset). When I fixed both of those problems on my Struts 1.1/Tomcat, I was able to validate properly client & server side without getting white pages and messed up Javascript. Regards, David -----Original Message----- From: Rich [mailto:[EMAIL PROTECTED] Sent: Friday, August 22, 2003 6:19 PM To: Struts Users Mailing List (E-mail) Subject: blank screen when validation fails. appears to be related to html:options I am having a problem with validating a html:select drop down. I think. The problem: after validation fails the JSP is blank (the browser is blank) not just an empty drop down. To be more specific...I load the page then without filling out any field I do a submit. It then does the javascript validation (I am only doing a required validation on one field at the moment) and displays the alert box. I click ok and then it appears the it then tries to do the server-side validation and fails. When it comes back instead of seeing the same page with the added validation messages rendered, it renders a blank screen. When I view source it shows the code prior to the html:javascript tag and then cuts off about 2/3 of the way through the validation JavaScript's. There is nothing to render after that. I thought my problem was related to some of the posts about the drop down not repopulating because when I comment out the lines with the bean:define and html:options that it then comes back from the validation failure with the correct view (instead of blank as mentioned above). But of course the drop down is empty because I commented out the lines to populate it. I tried a few of those suggestion but could not get the page to display with those lines uncommented. One thing that may be worth mention is that I get the list for the drop down with a "public List getAdjustTypes()" on the form. I could use some help at this point (well I always need help) since my brain just short circuited about 20 minutes ago. Here is my code: ----------------------------------------------------------- The SP ----------------------------------------------------------------- <?xml version="1.0" encoding="windows-1252"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <%@ taglib uri="/WEB-INF/struts-tiles.tld" prefix="tiles" %> <%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %> <%@ taglib uri="/WEB-INF/czee-tags.tld" prefix="cz" %> <%@ taglib uri="/WEB-INF/c.tld" prefix="c" %> <%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %> <%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %> <script language="JavaScript" src="<html:rewrite page='/pages/navbarUtils.js'/>"></script> <script language="JavaScript" src="<html:rewrite page='/pages/dt_select.js'/>" ></script> <script language="JavaScript"> function cancelAdjustment(form) { form.action='<html:rewrite page="/checkCancel.do" />'; form.submit(); } </script> <html:javascript formName="checkAdjustmentForm" /> <html> <head> <META HTTP-EQUIV="PRAGMA" CONTENT="NO-CACHE"> <html:base /> <title>Account Adjustment</title> <link href="<html:rewrite page='/pages/default.css'/>" rel="stylesheet" type="text/css"> </head> <body> <html:form action="/checkRegisterAdjustSave" focus="checkMemo" onsubmit="validateForm(this,validateCheckAdjustmentForm)"> <SCRIPT language="JavaScript"> currentForm=checkAdjustmentForm; </SCRIPT> <html:hidden property="bankId" /> <html:hidden property="objectId" /> <table width="100%" cellspacing="0" cellpadding="0" border="0"> <tr> <td colspan="2" > <table width="100%"> <tr ><td class="mainPageName"><bean:message key="check.adjust.header"/></td></tr> </table> </td> <tr> <td colspan="2" class="mainTextCtr"> <cz:label property="check.checkMemo" /><br/> <html:text styleClass="formTextField240" property="checkMemo" maxlength="80" /> </td> </tr> <tr> <td class="mainTextLt"> <cz:label property="check.adjust.type" /><br/> <bean:define id="adjustTypes" name="checkAdjustmentForm" property="adjustTypes" /> <html:select property="adjustType" styleClass="formTextField120" > <option/> <html:options collection="adjustTypes" property="value" labelProperty="label" /> </html:select><bean:message key="default.blankSpace" /> </td> <td class="mainTextLt"> <cz:label property="check.checkAmount" /><br/> <html:text styleClass="formTextField120" property="checkAmount" /> </td> </tr> <tr> <td colspan="2" class="mainTextCtr"> <cz:label property="check.date" /><br/> <cz:dateselect property="checkDate" calendarImage="calendar.gif" styleClass="formTextField80" formUsed="checkAdjustmentForm" fieldUsed="checkDate" displayTime="false" /> </td> </tr> <tr> <td> <bean:message key="default.blankSpace" /> </td> </tr> <tr> <td colspan="2" class="mainTextCtr"> <html:submit property="Search" styleClass="formSubmit" > <cz:label property="button.ok" /> </html:submit> <bean:message key="default.blankSpace" /> <c:set var="closeThis" >location.href='<html:rewrite page='/checkCancel.do' />'</c:set> <html:button property="requiredButNotNeeded" styleClass="formSubmit" onclick="cancelAdjustment(currentForm)"> <cz:label property="button.cancel" /> </html:button> </td> </tr> </table> <logic:messagesPresent > <bean:message key="errors.header" /> <html:messages id="error" message="false" > <bean:message key="errors.prefix" /> <bean:write name="error" /><br/> <bean:message key="errors.suffix" /> </html:messages> <bean:message key="errors.footer" /> </logic:messagesPresent> </html:form> </body> </html> ---------------------------------------------------------------------------- ---- The Form ----------------------------------------------------------- package com.mvsc.czee.forms.financial.check; import com.mvsc.czee.business.financial.Journal; import com.mvsc.czee.business.contacts.Contact; import com.mvsc.czee.business.claims.Claimant; import com.mvsc.czee.business.insured.Insured; import com.mvsc.czee.business.bankAccount.BankAccount; import com.mvsc.czee.persistence.Persistence; import com.mvsc.czee.persistence.SearchObject; import com.mvsc.czee.SymbolConstants; import java.util.Iterator; import java.util.List; import java.util.ArrayList; import java.util.ListIterator; import java.sql.SQLException; import cirrus.hibernate.HibernateException; import org.apache.log4j.Logger; import org.apache.struts.util.LabelValueBean; import org.apache.struts.util.MessageResources; import org.apache.struts.action.ActionMapping; import org.apache.struts.action.Action; import javax.servlet.ServletRequest; /** * (enter description here) * <P> * Examples(s): * <PRE> * Class clazz = new Class(); * clazz.doSomething(); * </PRE> * <P> * $Revision: $ <BR/> * $Created: Aug 6, 2003 at 1:24:03 PM $ * @author Richard Conover * @author Copyright © 2003 MountainView Software */ public class CheckEditForm extends CheckDataForm implements SymbolConstants { private static Logger logger = Logger.getLogger(CheckEditForm.class); private static final String SQL_ERROR = "SQL Exception trying to lookup linked info, class: "; private static final String HIBERNATE_ERROR = "Hibernate Exception trying to lookup linked info, class: "; private static final String KEY_MESSAGE = ", key is: "; private String searchPayee; private String searchCheckNumberFrom; private String searchCheckNumberTo; private String searchCheckDateFrom; private String searchCheckDateTo; private String searchAmountFrom; private String searchAmountTo; private String searchZeroChecks; private String searchBankSelected; private String changesMade; private Iterator checkResults; //used when the uses voids or stops payment on a check private String reasonDesc; // display fields, which are the result of chasing the id links above private String claimantName; private String insuredName; private String contactName; //todo add benificiary // private String beneficiaryName; private String payee; // derived based on which id is set private String payeeType; // holds select value for payee type private String journalTypeName; private String adjustType; private String adjustTypeDesc; private String action; MessageResources messages; public String getAdjustType() { return adjustType; } public void setAdjustType(String adjustType) { this.adjustType = adjustType; } public String getAdjustTypeDesc() { return adjustTypeDesc; } public void setAdjustTypeDesc() { if (this.getAdjustType() != null && !this.getAdjustType().equals(EMPTY_STRING)) { Journal.AdjustTypeCode type = Journal.AdjustTypeCode.getAdjustTypeCode(new Integer(this.getAdjustType())); if (type != null) { // get the string representation adjustTypeDesc = messages.getMessage(type.getAppKey()); } else { // none set yet, just zap it adjustTypeDesc = EMPTY_STRING; } } } public String getJournalTypeName() { return journalTypeName; } public void setJournalTypeName() { if (this.getJournalType() != null && !this.getJournalType().equals(EMPTY_STRING)) { Journal.JournalTypeCode type = Journal.JournalTypeCode.getJournalTypeCode(new Integer(this.getJournalType())); if (type != null) { // get the string representation journalTypeName = messages.getMessage(type.getAppKey()); } else { // none set yet, just zap it journalTypeName = EMPTY_STRING; } } } public String getAction() { return action; } public void setAction(String action) { this.action = action; } public MessageResources getMessages() { return messages; } public void setMessages(MessageResources messages) { this.messages = messages; } public String getClaimantName() { return claimantName; } public void setClaimantName(String claimantName) { this.claimantName = claimantName; } public String getInsuredName() { return insuredName; } public void setInsuredName(String insuredName) { this.insuredName = insuredName; } public String getContactName() { return contactName; } public void setContactName(String contactName) { this.contactName = contactName; } public String getPayeeType() { return payeeType; } public void setPayeeType(String payeeType) { this.payeeType = payeeType; } public String getSearchPayee() { return searchPayee; } public void setSearchPayee(String searchPayee) { this.searchPayee = searchPayee; } public String getSearchCheckNumberFrom() { return searchCheckNumberFrom; } public void setSearchCheckNumberFrom(String searchCheckNumberFrom) { this.searchCheckNumberFrom = searchCheckNumberFrom; } public String getSearchCheckNumberTo() { return searchCheckNumberTo; } public void setSearchCheckNumberTo(String searchCheckNumberTo) { this.searchCheckNumberTo = searchCheckNumberTo; } public String getSearchCheckDateFrom() { return searchCheckDateFrom; } public void setSearchCheckDateFrom(String searchCheckDateFrom) { this.searchCheckDateFrom = searchCheckDateFrom; } public String getSearchCheckDateTo() { return searchCheckDateTo; } public void setSearchCheckDateTo(String searchCheckDateTo) { this.searchCheckDateTo = searchCheckDateTo; } public String getSearchAmountFrom() { return searchAmountFrom; } public void setSearchAmountFrom(String searchAmountFrom) { this.searchAmountFrom = searchAmountFrom; } public String getSearchAmountTo() { return searchAmountTo; } public void setSearchAmountTo(String searchAmountTo) { this.searchAmountTo = searchAmountTo; } public String getSearchZeroChecks() { return searchZeroChecks; } public void setSearchZeroChecks(String searchZeroChecks) { this.searchZeroChecks = searchZeroChecks; } public String getSearchBankSelected() { return searchBankSelected; } public void setSearchBankSelected(String searchBankSelected) { this.searchBankSelected = searchBankSelected; } public String getChangesMade() { return changesMade; } public void setChangesMade(String changesMade) { this.changesMade = changesMade; } public Iterator getCheckResults() { return checkResults; } public void setCheckResults(Iterator checkResults) { this.checkResults = checkResults; } public String getReasonDesc() { return reasonDesc; } public void setReasonDesc(String reasonDesc) { this.reasonDesc = reasonDesc; } public String getPayee() { return payee; } public void setPayee() { // sets payee type, too Journal.PayeeType type = null; if (this.getContactId() != null && !this.getContactId().equals(EMPTY_STRING)) { Contact contact = (Contact) chaseLink(Contact.class, this.getContactId()); contactName = contact.getFirstName() + SPACE + contact.getLastName(); contactName.trim(); payee = contactName; type = Journal.PayeeType.VENDOR; } else if (this.getClaimantId() != null && !this.getClaimantId().equals(EMPTY_STRING)) { Claimant claimant = (Claimant) chaseLink(Claimant.class, this.getClaimantId()); claimantName = claimant.getFirstName() + SPACE + claimant.getLastName(); claimantName.trim(); payee = claimantName; type = Journal.PayeeType.CLAIMANT; } else if (this.getInsuredId() != null && !this.getInsuredId().equals(EMPTY_STRING)) { Insured insured = (Insured) chaseLink(Insured.class, this.getInsuredId()); insuredName = insured.getName(); payee = insuredName; type = Journal.PayeeType.INSURED; //todo add benificiary // } else if (this.getBeneficiaryId() != null && !this.getBeneficiaryId().equals(EMPTY_STRING)) { // //Beneficiary beneficiary = (Beneficiary) chaseLink(Beneficiary.class, this.getBeneficiaryId()); // //beneficiaryName = beneficiary.getName(); // beneficiaryName = EMPTY_STRING;//replace w/ above when ready // payee = beneficiaryName; // type = Journal.PayeeType.BENEFICIARY; } else { // no Id set yet payee = EMPTY_STRING; } if (type != null) { // get the string representation payeeType = String.valueOf(type.getDbValue()); } else { // none set yet, just zap it payeeType = EMPTY_STRING; } } private static Object chaseLink(Class clazz, String id) { // lookup a data object based on the link passed in Object result = null; if (id != null && !id.equals(EMPTY_STRING)) { // there is an id specified, get the object logger.debug("In lookup, class is: " + clazz.getName() + ", id is: " + id); Long key = new Long(id); try { result = Persistence.getInstance().load(clazz, key); } catch (SQLException e) { logger.error(SQL_ERROR + clazz.getName() + KEY_MESSAGE + key, e); } catch (HibernateException e) { logger.error(HIBERNATE_ERROR + clazz.getName() + KEY_MESSAGE + key, e); } } return result; } public List getPayeeTypes() { List selectList = new ArrayList(); // the one we're building List enumList = Journal.PayeeType.getList(); // the enumeration ListIterator li = enumList.listIterator(); while (li.hasNext()) { Journal.PayeeType type = (Journal.PayeeType) li.next(); String translation = messages.getMessage(type.getAppKey()); selectList.add(new LabelValueBean(translation, String.valueOf(type.getDbValue()))); } return selectList; } public List getJournalTypes() { List selectList = new ArrayList(); // the one we're building List enumList = Journal.JournalTypeCode.getList(); // the enumeration ListIterator li = enumList.listIterator(); while (li.hasNext()) { Journal.JournalTypeCode type = (Journal.JournalTypeCode) li.next(); String translation = messages.getMessage(type.getAppKey()); selectList.add(new LabelValueBean(translation, String.valueOf(type.getDbValue()))); } return selectList; } public List getAdjustTypes() { List selectList = new ArrayList(); // the one we're building List enumList = Journal.AdjustTypeCode.getList(); // the enumeration ListIterator li = enumList.listIterator(); while (li.hasNext()) { Journal.AdjustTypeCode type = (Journal.AdjustTypeCode) li.next(); String translation = messages.getMessage(type.getAppKey()); selectList.add(new LabelValueBean(translation, String.valueOf(type.getDbValue()))); } return selectList; } public List getBankAccounts() throws SQLException, HibernateException { List selectList = new ArrayList(); // the one we're building SearchObject searchObj = new SearchObject(BankAccount.class); List enumList = Persistence.getInstance().find(searchObj); //all the bank accounts ListIterator li = enumList.listIterator(); while (li.hasNext()) { BankAccount bankAccount = (BankAccount) li.next(); selectList.add(new LabelValueBean(bankAccount.getBankDescTxt(), bankAccount.getId().toString())); } return selectList; } public void reset(ActionMapping actionMapping, ServletRequest servletRequest) { messages = (MessageResources)servletRequest.getAttribute(Action.MESSAGES_KEY); } } ---------------------------------------------------------------------------- ---- The Action ----------------------------------------------------------- package com.mvsc.czee.actions.financial.check; import com.mvsc.czee.actions.RuleAction; import com.mvsc.czee.business.financial.Journal; import com.mvsc.czee.forms.financial.check.CheckEditForm; import com.mvsc.utils.FormUtils; import com.mvsc.utils.ForwardUtil; import com.mvsc.utils.SessionUtils; import com.mvsc.utils.SessionResourceException; import org.apache.struts.action.ActionForward; import org.apache.struts.action.ActionMapping; import org.apache.struts.action.ActionForm; import org.apache.log4j.Logger; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; /** * (enter description here) * <P> * Examples(s): * <PRE> * Class clazz = new Class(); * clazz.doSomething(); * </PRE> * <P> * $Revision: $ <BR/> * $Created: Aug 19, 2003 at 3:03:08 PM $ * @author Richard Conover * @author Copyright © 2003 MountainView Software */ public class AccountAdjustmentNewAction extends RuleAction { private static Logger logger = Logger.getLogger(AccountAdjustmentNewAction.class); private static String BANK_ID = "BankId"; private static final String ACTION_STARTED = "AccountAdjustmentNewAction invoked."; private static final String ACTION_COMPLETED = "AccountAdjustmentNewAction completed."; public ActionForward secureExecute(ActionMapping mapping, ActionForm form, HttpServletRequest hreq, HttpServletResponse hres) throws Exception { logger.debug(ACTION_STARTED); String result = SUCCESS; // assume success // get the id that was passed to us from the search screen logger.debug("BankID: " + hreq.getParameter(BANK_ID)); Long id = new Long(hreq.getParameter(BANK_ID)); try { Journal journal = (Journal) SessionUtils.getAttribute(Journal.class, null, null, hreq); //put the business object data in the checkEditForm CheckEditForm editForm = (CheckEditForm) form; FormUtils.copyBusinessToForm(journal, editForm); // get the message resource bundle for this request editForm.setMessages(this.getResources(hreq)); //set the bankid so it is forwarded to the save action editForm.setBankId(id.toString()); } catch (SessionResourceException e) { // out of resources result = FAILURE; } logger.debug(ACTION_COMPLETED); return ForwardUtil.findForward(this, mapping, result); } } -------------------------------------------------------------------- The Struts Config appings ------------------------------------------------------- <action path="/checkRegisterAdjust" type="com.mvsc.czee.actions.financial.check.AccountAdjustmentNewAction" name="checkAdjustmentForm" validate="false" scope="request"> <forward name="failure" path="/checkSessionList.do"/> <forward name="success" path="/pages/accountAdjustment.jsp"/> </action> <action path="/checkRegisterAdjustSave" type="com.mvsc.czee.actions.financial.check.AccountAdjustmentSaveAction" name="checkAdjustmentForm" scope="request" input="/pages/accountAdjustment.jsp" validate="true"> <forward name="success" path="/pages/close_window.jsp"/> </action> ----------------------------------------------------------------------- The Validation apping -------------------------------------------------------------- <form name="checkAdjustmentForm"> <field property="checkMemo" depends="required"> <arg0 key="check.checkMemo" /> </field> <!-- <field property="adjustType" depends="required">--> <!-- <arg0 key="check.adjust.type" />--> <!-- </field>--> <!-- <field property="checkAmount" depends="required">--> <!-- <arg0 key="check.checkAmount" />--> <!-- </field>--> <!-- <field property="checkDate" depends="required">--> <!-- <arg0 key="check.date" />--> <!-- </field>--> </form> Thanks, Richard Conover Developer MountainView Software Products and Services Gallagher Bassett Services, Inc. Phone: 801-544-2446 Ext. 320 Fax: 866-741-0545 [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]