Struts2.xml: action result type of redirect-action or redirectAction shows as errors.

In Intellij IDEA Ultimate 9.0, my struts 2 config file is showing up entirely in red, and most of the errors are:
"Cannot resolve result-type 'redirectAction'" or "Cannot resolve result-type 'redirect-action'" (Both of which work fine in my webapp.)

I'm using struts 2.0.14, and here's the API reference on this type: http://struts.apache.org/2.x/docs/redirect-action-result.html

Here's a sample file to highlight what exactly I'm talking about:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
        "http://struts.apache.org/dtds/struts-2.0.dtd">

<struts>
    <package name="stuff" namespace="/stuff">
        <action name="listStuff" method="list">
            <result>/WEB-INF/pages/stuff/stuffList.jsp</result>
        </action>
        <action name="viewStuff" method="view">
            <result name="success">/WEB-INF/pages/stuff/stuffView.jsp</result>
        </action>
        <action name="editStuff" method="edit">
            <result>/WEB-INF/pages/stuff/stuffForm.jsp</result>
            <result name="cancel" type="redirectAction">
                <param name="actionName">listStuff</param>
                <param name="namespace">/stuff</param>
            </result>
        </action>
        <action name="saveStuff" method="save">
             <result name="input">/WEB-INF/pages/stuff/stuffForm.jsp</result>
            <result name="success" type="redirect-action">viewStuff?stuff.id=${stuff.id}</result>
        </action></struts>

(Using redirect-action or redirectAction, and using param name actionName/namespace tags or not makes no difference, still shows up as errors.)

Also the "stuff.id" that is in bold shows up as this error: "Cannot resolve symbol 'stuff.id'" (This is just calling getStuff().getId() on the action to pass the id of the object to the action for viewing it, and works fine in the webapp.)

Any ideas what this is all about???

7 comments
Comment actions Permalink

Hello alex, please make sure to include struts.xml from your struts.jar in your S2-fileset.   Yann

1
Comment actions Permalink

Thanks Yann!  Including my struts.xml file from my struts.jar in my S2 fileset DOES suppress all the errors about my <result types> of "redirect-action" or "redirectAction"!

My config file is still mostly red though, since all my result values using references like ${stuff.id} are still showing up as errors though, as follows (with "Cannot resolve symbol "stuff.id" error messages):

<struts>
    <package name="stuff" namespace="/stuff">
        <action name="listStuff" method="list">
            <result>/WEB-INF/pages/stuff/stuffList.jsp</result>
        </action>
        <action name="viewStuff" method="view">
            <result name="success">/WEB-INF/pages/stuff/stuffView.jsp</result>
        </action>
        <action name="editStuff" method="edit">
            <result>/WEB-INF/pages/stuff/stuffForm.jsp</result>
            <result name="cancel" type="redirectAction">
                <param name="actionName">listStuff</param>
                <param name="namespace">/stuff</param>
            </result>
        </action>
        <action name="saveStuff" method="save">
             <result name="input">/WEB-INF/pages/stuff/stuffForm.jsp</result>
            <result name="success" type="redirect-action">viewStuff?stuff.id=${stuff.id}</result>
        </action></struts>

Any idea how to get those to not show up as errors, anyone?

0
Comment actions Permalink

Hello Alex,  sorry for delay due to holidays.  What version of IDEA are you using? Can you please give the name of the inspection which higlights your EL-expressions (press Alt-Enter to see context menu with inspection name)?  Thanks,   Yann

0
Comment actions Permalink

I'm using Intellij IDEA Ultimate 9.0.3 (#IU-95.429)

When I mouse over the "Cannot resolve symbol' errors, I see a light bulb where hitting Alt-Enter just shows me Inject Language and Split current tag popup menus, so I'm not sure how to get IDEA to show me the inspection name that is causing the error.

It doesn't show me the "Inspection <inspection name> options" menu for that with the disable/suppress options like on invalid method names  in the struts config.

0
Comment actions Permalink

Please check your language injection settings (easiest way to test: disable "IntelliLang"-plugin completely) and let me know if this helps.  Greetings,  Yann

0
Comment actions Permalink

I disabled my IntelliLang plugin and restarted, but all the same 'Cannot resolve symbol' errors were highlighted.

What I'm trying to do with my struts config block:

<action name="saveStuff" method="save">
             <result name="input">/WEB-INF/pages/stuff/stuffForm.jsp</result>
            <result name="success" type="redirect-action">viewStuff?stuff.id=${stuff.id}</result>
</action>

is "Embedding OGNL to create dynamic locations" as described on page 221 of Manning's Struts 2 In Action book, where part of my struts result is set dynamically from the value stack.

Maybe the struts2 plugin just doesn't currently understand this OGNL usage? (I don't see any alternate notation for doing this, you must use the ${} notation according to page 221 of the previously mentioned struts2 book.)

(It seems like the struts2 plugin could see ${stuff.id} and check the class com.acme.webapp.action.StuffAction for a getStuff() method, and check to make sure whatever object that method returns has a getId() method as well.)

0
Comment actions Permalink

I cannot reproduce this error highlighting with Intellij IDEA Ultimate 9.0.3 (#IU-95.429) and my currently enabled plugins.   Please try disabling all plugins and re-enable them one by one to find out which one might be the cause.  Thanks,   Yann

0

Please sign in to leave a comment.