Don't worry about those exceptions. The params interceptor is trying
to bind those parameters to your action and it is failing. If you want
to silence the param interceptor, it has a "excludeParams" property
that takes a list of regular expressions:
<interceptor-ref name="params">
<param name="excludeParams">dojo\..*</param>
</interceptor-ref>
will ignore any parameter that has "dojo." in it.
musachy
On Mon, Jun 16, 2008 at 11:31 AM, Karr, David <[EMAIL PROTECTED]> wrote:
> So far I think the client side is getting the correct response, both
> with and without field errors (although I haven't plugged in the
> automated processing of the field errors on the client side yet).
> However, on the server side I'm seeing two exceptions (the other is for
> the other property, "validateOnly"):
>
> ognl.OgnlException: target is null for setProperty(null,
> "enableJSONValidation", [Ljava.lang.String;@a4ed99)
> at ognl.OgnlRuntime.setProperty(OgnlRuntime.java:1651)
> at ognl.ASTProperty.setValueBody(ASTProperty.java:101)
> at ognl.SimpleNode.evaluateSetValueBody(SimpleNode.java:177)
> at ognl.SimpleNode.setValue(SimpleNode.java:246)
> at ognl.ASTChain.setValueBody(ASTChain.java:172)
> at ognl.SimpleNode.evaluateSetValueBody(SimpleNode.java:177)
> at ognl.SimpleNode.setValue(SimpleNode.java:246)
> at ognl.Ognl.setValue(Ognl.java:476)
> at
> com.opensymphony.xwork2.ognl.OgnlUtil.setValue(OgnlUtil.java:197)
> at
> com.opensymphony.xwork2.ognl.OgnlValueStack.setValue(OgnlValueStack.java
> :150)
> at
> com.opensymphony.xwork2.ognl.OgnlValueStack.setValue(OgnlValueStack.java
> :138)
> at
> com.opensymphony.xwork2.interceptor.ParametersInterceptor.setParameters(
> ParametersInterceptor.java:205)
>
> When examining the request parameters, the values for each of these is a
> single element array with the value "true".
>
> In Firebug, it shows the POST parameters as:
>
> firstName joe
> lastName blow
> struts.enableJSONValidation true
>
> As I said, despite these exceptions, the client side appears to be
> getting the correct response, so the server side is clearly receiving
> and setting the "enableJSONValidation" flag. I don't know what other
> symptoms the exception might be causing. I don't see anything yet.
>
>> -----Original Message-----
>> From: Musachy Barroso [mailto:[EMAIL PROTECTED]
>> Sent: Sunday, June 15, 2008 5:09 PM
>> To: Struts Users Mailing List
>> Subject: Re: Some confusion trying to do ajax form submit
>>
>> Take a look at this (2.1 only):
>>
>> http://struts.apache.org/2.0.11.1/docs/ajax-validation.html
>>
>> musachy
>>
>> On Sun, Jun 15, 2008 at 8:02 PM, Karr, David
>> <[EMAIL PROTECTED]> wrote:
>> > I have a simple page with validation that I got working with a
>> > conventional submit and action.
>> >
>> > I'm now trying to explore doing an Ajax form submit, and getting a
>> > JSON response. I'm using YUI on the client side. I'd like
>> to see if
>> > I can get similar data in the JSON response that I would in
>> a normal
>> > submit, for instance, with field errors.
>> >
>> > There are a couple points I could use some help with, not
>> necessarily
>> > related to Ajax or JSON. Please don't hesitate to tell me if I'm
>> > doing something else wrong, or something I should be aware of.
>> >
>> > My first attempt actually did execute the Ajax request, and got the
>> > response, but it wasn't JSON. The responseText was just
>> the HTML of
>> > my source JSP, which is also the value of my "input"
>> result. I tried
>> > setting up the JSON action without an "input" result, but
>> it seemed to
>> > complain if I didn't have that. I would have thought the "input"
>> > parameter wouldn't be relevant in a Ajax/JSON action. If I
>> filled in
>> > all the required fields so it didn't result in any field
>> errors, the
>> > response was JSON, and it was reasonable (although setting
>> > "wrapWithComments" didn't appear to have any effect). I
>> guess there's
>> > no automatic provision for reporting field errors in a JSON
>> response,
>> > so I guess I'll have to build something like that by hand?
>> >
>> > Note that I tried to enable the logging interceptor, but I
>> didn't see
>> > any output from it.
>> >
>> > I have a single action that I was intending to use to
>> handle both the
>> > ajax and non-ajax submit. I tried to make it use two
>> different action
>> > names in the form, but it seemed to have trouble with that.
>> >
>> > I noticed in the generated HTML, I had this in the HTML for the form
>> > tag:
>> >
>> > onsubmit="return YAHOO.strutsform.submitform();;
>> return true;"
>> >
>> > I'm not sure if that "return true;" will cause me trouble, as I'm
>> > trying to bypass the normal form submission. I think by returning
>> > false from "submitform", I achieved that, however.
>> >
>> > I'll include here the relevant files. Please comment where
>> appropriate.
>> > Thanks for your input.
>> > ---form.jsp------------
>> > <%@ page language="java" contentType="text/html; charset=UTF-8"
>> > pageEncoding="UTF-8"%>
>> > <%@ taglib prefix="s" uri="/struts-tags" %> <!DOCTYPE html PUBLIC
>> > "-//W3C//DTD HTML 4.01 Transitional//EN"
>> > "http://www.w3.org/TR/html4/loose.dtd">
>> > <html>
>> > <head>
>> > <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
>> > <title>Struts Form</title> <link rel="stylesheet"
>> >
>> href="${pageContext.request.contextPath}/struts/css_xhtml/styles.css"
>> > type="text/css">
>> > <link rel="stylesheet" type="text/css"
>> > href="${pageContext.request.contextPath}/style/form.css">
>> > <!-- css -->
>> > <link rel="stylesheet" type="text/css"
>> >
>> href="${pageContext.request.contextPath}/yui/reset-fonts-grids/reset-f
>> > on
>> > ts-grids.css">
>> > <link rel="stylesheet" type="text/css"
>> >
>> href="${pageContext.request.contextPath}/yui/button/assets/skins/sam/b
>> > ut
>> > ton.css">
>> > <link rel="stylesheet" type="text/css"
>> >
>> href="${pageContext.request.contextPath}/yui/logger/assets/skins/sam/l
>> > og
>> > ger.css">
>> > <!-- js -->
>> > <script type="text/javascript"
>> >
>> src="${pageContext.request.contextPath}/yui/utilities/utilities.js"></
>> > sc
>> > ript>
>> > <script type="text/javascript"
>> >
>> src="${pageContext.request.contextPath}/yui/button/button-debug.js"></
>> > sc
>> > ript>
>> > <script type="text/javascript"
>> >
>> src="${pageContext.request.contextPath}/yui/json/json-debug.js"></scri
>> > pt
>> >>
>> > <script type="text/javascript"
>> >
>> src="${pageContext.request.contextPath}/yui/logger/logger-debug.js"></
>> > sc
>> > ript>
>> > <script type="text/javascript"
>> >
>> src="${pageContext.request.contextPath}/scripts/strutsform.js"></scrip
>> > t>
>> > </head>
>> > <body class="yui-skin-sam">
>> > <h4>Enter your data</h4>
>> > <!-- onsubmit="return YAHOO.strutsform.submitform();" -->
>> > <s:form id="form" action="Form" onsubmit="return
>> > YAHOO.strutsform.submitform();">
>> > <s:textfield name="lastName" label="Last Name"/>
>> > <s:textfield name="firstName" label="First Name"/>
>> > <button id="formsubmit" type="submit">Submit</button>
>> > </s:form>
>> > <script type="text/javascript">
>> > YAHOO.util.Event.onDOMReady(YAHOO.strutsform.init);
>> > </script >
>> > </body>
>> > </html>
>> > ---------------
>> > ---struts.xml------------
>> > <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE struts PUBLIC
>> > "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
>> > "struts-2.0.dtd" > <struts>
>> > <constant name="struts.devMode" value="true" />
>> > <package extends="struts-default" name="main" namespace="/main">
>> > <action name="main">
>> > <result>/form.jsp</result>
>> > </action>
>> > <action name="Form" class="com.wamu.strutsform.FormAction">
>> > <result name="input">/form.jsp</result>
>> > <result>/form.jsp</result>
>> > </action>
>> > </package>
>> >
>> > <package extends="json-default" name="json" namespace="/json">
>> > <action name="Form" class="com.wamu.strutsform.FormAction"
>> > method="jsonSubmit">
>> > <interceptor-ref name="logger"></interceptor-ref>
>> > <interceptor-ref name="completeStack"></interceptor-ref>
>> > <result type="json">
>> > <param name="wrapWithComments">true</param>
>> > </result>
>> > <result name="input">/form.jsp</result>
>> > </action>
>> > </package>
>> > </struts>
>> > ---------------
>> > ---FormAction.java------------
>> > package com.wamu.strutsform;
>> > import org.apache.commons.logging.Log; import
>> > org.apache.commons.logging.LogFactory;
>> > import com.opensymphony.xwork2.ActionSupport;
>> >
>> > public class FormAction extends ActionSupport {
>> > private static final Log logger =
>> > LogFactory.getLog(FormAction.class);
>> >
>> > private String lastName;
>> > private String firstName;
>> >
>> > public String getLastName() { return lastName; }
>> > public String getFirstName() { return firstName; }
>> >
>> > public void setLastName(String lastName)
>> > { this.lastName = lastName; }
>> > public void setFirstName(String firstName)
>> > { this.firstName = firstName; }
>> >
>> > public String execute()
>> > {
>> > logger.info("execute.");
>> > return SUCCESS;
>> > }
>> >
>> > public String jsonSubmit()
>> > {
>> > logger.info("jsonSubmit.");
>> > return SUCCESS;
>> > }
>> > }
>> > ---------------
>> > ---strutsform.js------------
>> > /**
>> > * @author u166705
>> > */
>> > YAHOO.namespace("strutsform");
>> >
>> > YAHOO.widget.Logger.enableBrowserConsole();
>> >
>> > var $E = YAHOO.util.Event;
>> > var $D = YAHOO.util.Dom;
>> >
>> > YAHOO.strutsform.init =
>> > function ()
>> > {
>> > $E.onContentReady("formsubmit", function()
>> > {
>> > var submitButton = new
>> YAHOO.widget.Button("formsubmit");
>> > });
>> > };
>> >
>> > YAHOO.strutsform.submitform =
>> > function()
>> > {
>> > var callback =
>> > {
>> > success: function(obj)
>> > {
>> > YAHOO.log("obj.responsetext[" +
>> obj.responseText + "]");
>> > },
>> > failure: function(obj)
>> > {
>> > YAHOO.log("obj.responseText[" +
>> obj.responseText + "]");
>> > }
>> > };
>> > YAHOO.util.Connect.setForm(document.getElementById("form"));
>> > YAHOO.util.Connect.asyncRequest("POST",
>> > "/strutsform/json/Form.action",
>> > callback, null);
>> > return false;
>> > };
>> > ---------------
>> >
>> >
>>
>>
>>
>> --
>> "Hey you! Would you help me to carry the stone?" Pink Floyd
>>
>> ---------------------------------------------------------------------
>> 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]
>
>
--
"Hey you! Would you help me to carry the stone?" Pink Floyd
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]