struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Mei Zhu" <>
Subject RE: JavaScript / struts submit problems
Date Tue, 28 Jan 2003 17:11:43 GMT
Just to add another note, it may not work(you need to verify by looking at
Java Bean spec) if you define your property name like xMLQueryString, but
xmlQueryString will work.


-----Original Message-----
From: Mei Zhu []
Sent: Tuesday, January 28, 2003 11:06 AM
To: Struts Users Mailing List
Subject: RE: JavaScript / struts submit problems

In your jsp page, the hidden field should be:
<html:hidden property="xMLQueryString"/> The first character of the property
name should be lower case.


-----Original Message-----
From: []
Sent: Tuesday, January 28, 2003 10:49 AM
Subject: JavaScript / struts submit problems

Hello All,

I am having a little problem that hopefully someone can help me with.  I
have a form that has a hidden field in it, I am not populating this hidden
field on the page load but rather I am populating the value in a JavaScript
function and then using the form.submit() in JavaScript to submit the form.
When I try pulling the value for the hidden field out in my Action class I
get either a null pointer exception or a zero length string depending on
how I try to get the data.  I have verified that there is data populating
in the hidden fields value.  Here is the code below, if anyone can help me
in finding out how to get the value I would be very grateful.


<%@ page language ="java"%>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html"%>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean"%>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic"%>
<title>Report Generator</title>
<LINK REL="stylesheet" TYPE="text/css" HREF="style/style.css">
<script LANGUAGE="JavaScript1.2" SRC="style/select.js"></script>
<script LANGUAGE="JavaScript1.2" SRC="style/report_generator.js"></script>
<script LANGUAGE="JavaScript1.2" SRC="style/dyn_select.js"></script>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<body bgcolor="#FFFFFF" text="#000000" leftmargin="0" topmargin="0">
<html:form action="Generator" name="generatorForm" type
<html:hidden property="XMLQueryString"/>
<table width = "100%" border = "0" cellpadding="0" cellspacing="0">
            <td align="left" valign="top">
                  <table width="197" border="0" height="103%" align="left"
valign="top" cellpadding="0" cellspacing="0">
                              <td height="90%" width="193" background
="images/bg_home_03.gif" >
                                    <table width="100%" border="0"
cellspacing="0" cellpadding="0">
                                                <td align="left">
<br><html:img src="images/load.gif" onmouseover="runtimeStyle.cursor
= 'hand'" onclick="runClick(document.generatorForm)"/> <br><br>
                                                <html:img onmouseover
="runtimeStyle.cursor = 'hand'" src="images/update.gif" onclick
="getHiddenValue(document.generatorForm)"/> <br> <br>
                                                <html:img onmouseover
="runtimeStyle.cursor = 'hand'" src="images/delete.gif"/> <br><br>
                                                <html:img onmouseover
="runtimeStyle.cursor = 'hand'" src="images/save.gif"/> <br><br>
                                                <html:text property
..... and so on.....


      function getHiddenValue(form)                          // added for
      function runClick(form)
            var strQueryXML = new String();

            if(form.selectedColumns.options.length > 0)
                  strQueryXML = getQueryXML(form);

                  form.XMLQueryString.value = strQueryXML;
                  alert(strQueryXML);                 // added for testing
                  alert(form.XMLQueryString.value);   // added for testing

                  alert("Please select at least one column.");

////Action Class/////

public class GeneratorAction  extends Action
  private ActionErrors errors = new ActionErrors();

  public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
      throws IOException, ServletException
    HttpSession session = request.getSession();
    String sXML = new String();
    String target = new String("failure");

    if(form != null)
      GeneratorForm gForm = (GeneratorForm)form;
        //sXML = gForm.getXMLQueryString();                 //0 length
        sXML = request.getAttribute("XMLQueryString").toString();
//null pointer
        //sXML = session.getAttribute("XMLQueryString").toString();
//null pointer
        System.out.println("XML String ="+sXML.toString());
        target = new String("success");
      catch(Exception e)
        System.out.println("Error Getting Attributes "+e);
        errors.add(ActionErrors.GLOBAL_ERROR, new ActionError
        target = new String("failure");


Tim Bachta
Information Technology
MC 48

To unsubscribe, e-mail:
For additional commands, e-mail:

To unsubscribe, e-mail:
For additional commands, e-mail:

To unsubscribe, e-mail:   <>
For additional commands, e-mail: <>

View raw message