Title: Message
If we did this, the Action would execute() before the params are set from the <ww:param> tags.
-----Original Message-----
From: Frederick N. Brier [mailto:[EMAIL PROTECTED]
Sent: Saturday, September 27, 2003 7:02 PM
To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
Subject: [OS-webwork] ActionTag wipes out own ActionContext

I have been back tracking through Webwork, XWork, and OGNL for the last several of hours (not being familiar with the codebase), and might have tracked down the problem.  Since I am just starting to use Webwork2, it would be great if someone else could tell me if this is the problem and whether my solution would be acceptable.

My app has an index.jsp page with an <ww:action id="homePage" name="homePage"/> and within the page a property tag: <ww:property value="lookAndFeel.title"/>
"lookAndFeel" is a property of the action specified by homePage.  It is an object that has a property "title".

When I debug the code, the doStartTag() of the <ww:property> tag shows the valueStack retrieved from the ActionContext has a size of 0, and so it exits - no value output.

ActionTag.doEndTag calls executeAction().  After all the trouble of creating a new ActionContext and associating it the current thread (below), the next line calls the DefaultActionProxy.execute() class which on exit, restores the previous ActionContext.  The ActionContext containing the valueStack with my Action class instance is gone.

ActionTag, Line 227, 228:
            proxy = ActionProxyFactory.getFactory().createActionProxy(namespace, name, createExtraContext(), executeResult);
            proxy.execute();

Sooo...  Possible solution: Have the ActionTag go back to the way it apparently worked in WW1, nesting around the contents of the JSP.  Move the functionality in the doEndTag() to the doStartTag().  Split the functionality in DefaultActionProxy.execute() into an invoke() method and a pop()/restore() method.  The pop() method is called in the doEndTag().
 
It might also be a thought to turn the ThreadLocal where ActionContext is stored into a stack itself and setContext() actually does a push() instead.

I can take a swag and fixing this, but would like some confirmation that this is the problem and would be an acceptable solution.  Thank you.

Fred.

At 11:28 AM 9/17/2003, Pat Lightbody wrote:
Hmm... not sure about all this -- It's been a while since i wrote the code. I'll check in to it.
----- Original Message -----
From: Jason Carreira
To: [EMAIL PROTECTED]
Sent: Monday, September 15, 2003 9:50 AM
Subject: RE: [OS-webwork] Request parameters not being set

I think the problem is the "id" property on the ActionTag itself. From the ActionTag:

 
private Map createExtraContext() {
        Map extraContext = Ognl.createDefaultContext(this);

 
        // Leave the ValueStack out -- We're not processing inside the tag
        //        OgnlValueStack vs = ActionContext.getContext().getValueStack();
        //        extraContext.put(ActionContext.VALUE_STACK, vs);
        Map parentParams = ActionContext.getContext().getParameters();
        Map newParams = (parentParams != null) ? new HashMap(parentParams) : new HashMap();

 
        if (params != null) {
            newParams.putAll(params);
        }

 
        extraContext.put(ActionContext.PARAMETERS, newParams);

 

 
Patrick, this would cause "id" to be in the extraContext, which would cause this problem when setting the params, right? Also, why are we leaving out the ValueStack? Don't we want to pass the ValueStack? We could pop the Action off afterwards if necessary...

 
Jason
-----Original Message-----
From: Chris Widhelm [mailto:[EMAIL PROTECTED]]
Sent: Monday, September 15, 2003 12:38 PM
To: [EMAIL PROTECTED]
Subject: Re: [OS-webwork] Request parameters not being set

Yep, it has both.  When I call the action directly it works fine (http://localhost:8080/secure/modules/admin/users/UserDetails.action?id=143).

 
Here is the class:
>>===================================================<<
package com.contego.arx.actions.user;

 
import com.contego.arx.domain.Person;
import com.opensymphony.xwork.ActionSupport;

 
public class Detail extends ActionSupport {
    private Integer id;
    private Person user;

 
    public String execute() throws Exception {
        user = Person.getPersonById(id);
        System.out.println( "Id: " + id );
        System.out.println( "User: " + user );

 
        return SUCCESS;
    }

 
    public Integer getId() { return id; }
    public void setId(Integer integer) {
        id = integer;
        System.out.println( "Setting ID: " + integer );
    }

 
    public Person getUser() { return user; }
    public void setUser(Person person) { user = person; }
}
>>===================================================<<
----- Original Message -----
From: Jason Carreira
To: [EMAIL PROTECTED]
Sent: Monday, September 15, 2003 11:27 AM
Subject: RE: [OS-webwork] Request parameters not being set

Does your Action have an "id" property? Does it have a getter and a setter? Sometimes the Java introspection stuff doesn't find a property with only a setter or only a getter...
-----Original Message-----
From: Chris Widhelm [mailto:[EMAIL PROTECTED]]
Sent: Monday, September 15, 2003 12:22 PM
To: [EMAIL PROTECTED]
Subject: Re: [OS-webwork] Request parameters not being set

In that case I already have the defaultStack set as the default interceptor which includes the ParameterInterceptor.

 
I have included all of the configuration as well as the jsp page that I am trying to access and the request.

 
Do you see anything that looks weird?

 
Still to no avail.  Here is my entire xwork.xml file.

 
>>=================================================<<
<!DOCTYPE xwork PUBLIC "-//OpenSymphony Group//XWork 1.0//EN" "http://www.opensymphony.com/xwork/xwork-1.0.dtd">

 
<xwork>
    <include file="webwork-default.xml"/>

 
    <package name="default" extends="webwork-default">

 
        <interceptors>
            <interceptor name="params" class="com.opensymphony.xwork.interceptor.ParametersInterceptor"/>

 
            <interceptor-stack name="defaultComponentStack">
                <interceptor-ref name="defaultStack"/>
            </interceptor-stack>
        </interceptors>

 
        <default-interceptor-ref name="defaultStack"/>

 
        <action name="UserDetails" class="com.contego.arx.actions.user.Detail">
            <result name="success" type="dispatcher">
                <param name="location">/secure/modules/admin/users/user_detail.jsp</param>
            </result>
        </action>

 
    </package>
</xwork>
>>=================================================<<

 
This is the JSP file that I am accessing:

 
>>=================================================<<
<%@ taglib uri="sitemesh-page" prefix="page" %>
<%@ taglib uri="webwork" prefix="ww" %>

 
<ww:action name="UserDetails" id="details"/>
<page:applyDecorator name="admin">
<table width="100%" cellpadding="2" cellspacing="0" border="0" class="STEP">
  <form action="" method="get">
    <ww:textfield label="First Name" name="FName" size="40" value="#details.user.FName"/>
  </form>
</table>
</page:applyDecorator>
>>=================================================<<

 
The request is:

 
http://localhost:8080/secure/modules/admin/users/edit_user.jsp?id=143

 

 

 

 
----- Original Message -----
From: Jason Carreira
To: [EMAIL PROTECTED]
Sent: Monday, September 15, 2003 10:55 AM
Subject: RE: [OS-webwork] Request parameters not being set

This is just for defining the interceptors. You need to specify which interceptors are applied to your actions.

 
If you look at http://wiki.opensymphony.com/space/Xwork+Configuration

 
You can see that Action elements have interceptor-refs inside:


 
       <action name="Foo" class="com.opensymphony.xwork.SimpleAction">

            <param name="foo">17</param>
            <param name="bar">23</param>
            <result name="success" type="chain">
                <param name="actionName">Bar</param>
            </result>
            <interceptor-ref name="debugStack"/>
            <interceptor-ref name="defaultStack"/>
        </action>

You can also supply a default interceptor-ref which will be applied to Actions if no other interceptor-ref is supplied, like so:

<package name="default" extends="webwork-default">

        <interceptors>

            <interceptor-stack name="defaultComponentStack">
                <interceptor-ref name="component"/>
                <interceptor-ref name="defaultStack"/>
            </interceptor-stack>
        </interceptors>

        <default-interceptor-ref name="defaultStack"/>

        ...

</package>

See also http://wiki.opensymphony.com/space/Using+webwork-default.xml
-----Original Message-----
From: Chris Widhelm [mailto:[EMAIL PROTECTED]]
Sent: Monday, September 15, 2003 11:15 AM
To: [EMAIL PROTECTED]
Subject: Re: [OS-webwork] Request parameters not being set

Is there any documentation on the available interceptors and how to configure them?

 
Here is my interceptor configuration section:

 
<interceptors>
    <interceptor name="params" class="com.opensymphony.xwork.interceptor.ParametersInterceptor"/>

 
    <interceptor-stack name="defaultComponentStack">
        <interceptor-ref name="component"/>
        <interceptor-ref name="defaultStack"/>
        <interceptor-ref name="params"/>
    </interceptor-stack>
</interceptors>

 
This doesn't seem to work.  *shrug*

 
The interceptor documentation that I have found in the xwork configuration section doesn't quite make it clear for me.
----- Original Message -----
From: Jason Carreira
To: [EMAIL PROTECTED]
Sent: Monday, September 15, 2003 10:03 AM
Subject: RE: [OS-webwork] Request parameters not being set

Did you apply the ParameterInterceptor to the Action? This is what sets the parameters into the Action.
-----Original Message-----
From: Chris Widhelm [mailto:[EMAIL PROTECTED]]
Sent: Monday, September 15, 2003 10:59 AM
To: [EMAIL PROTECTED]
Subject: [OS-webwork] Request parameters not being set

I am in the process of switching to WW2 from WW1 and it appears that the parameters on a request are no longer being automatically set for an action.  Is this the case?

 
How do I access the parameters on a request?

 
Thanks,

 
Chris

Reply via email to