And here is the patch :P

Benjamin Venditti schrieb:
Hi Rainer,

i tested both web applications and couldn't find any problems. However 2 more 
things had to be fixed and therefore i updated the patch (included in this 
mail).

About the problem with the "targets" property of the "Anchor" class. 
Unfortunately i couldn't find the sources for sturts 2.0.11 but i had a look in the sources of 
2.0.12.
To me it looks like that the property "targets" has been removed without replacement and the property "href", which was 
previously inherited from "AbstractRemoteCallUIBean", has now moved to "Anchor" directly itself. Another point why i 
think that "href" is not is not the replacement for "targets" is the drescription in the sources.
    targes:     Comma delimited list of ids of the elements whose content will 
be updated
    href:        The URL.

Please let me know what you think about it.

best regards,
    benjamin



-----Ursprüngliche Nachricht-----
Von: "Rainer Döbele" <[email protected]>
Gesendet: 09.07.09 16:10:11
An: <[email protected]>
Betreff: re: Uprading struts2 extensions to struts 2.1.6

Hi Benni,

I have actually compared the Struts2 source code of 2.0.11 and 2.1.6 (which you 
should have as well) and to me it looked as if they have just renamed targets 
to href. But I might be wrong. Just have a go and see what happens. It should 
go in there and the result should be obvious.

Benjamin Venditti wrote:
re: Uprading struts2 extensions to struts 2.1.6

Hi Rainer,

thanks for your response and hints. For the first issue (ItemListTag)
your suggestion looks like the right solution (i also found the
comments in the source).
However for the second issue (LinkTag / Anchor) i am not so sure as the
"href" property already existed before and therefore i think its not
the appropriate replacement.
Previous struts APIs referred to 'targets' as list of element ids whose
content will be updated with the text returned from request
I couldn't find any similar property that could represent that nature.
I also do not really understand what that means, afaik "target" can
have values like "_blank, _parent ...".

I created a patch that affects 12 files and can easily be apply with
Eclipse (right click -> team -> Apply Patch ...). After you have
applied the patch you can find my
changes and comments by searching the string "* UPGRADE-struts 2.1.6"
in the source code.

I'll have to do further testing, but with the patch you can have a
first look.

best regards,
    Benjamin




-----Ursprüngliche Nachricht-----
Von: "Rainer Döbele" <[email protected]>
Gesendet: 06.07.09 21:01:04
An: <[email protected]>
Betreff: re: Uprading struts2 extensions to struts 2.1.6

Hi Benni,

first of all it's certainly a great idea to update our dependencies to
the latest struts2 release.
Thanks to Maven changing version is simple, however there seem to be
quite a few problems of which you must have already solved quite a few.

Without doing your work again I cannot compile and run the code, hence
your questions are hard to answer just by looking at the code.
But since this was my only option I gave it a go and this is my
conclusion:

1. In the class ItemListTag you should replace getId()/setId() by
getVar()/setVar()

2. In the classes LinkTag and AnchorComponent you should replace the
property "targets" by "href" and use setHref() instead of setTargets()
respectively.

That could do the job (as I said this is untested - only concluded from
reading the struts2 source code).
But of course you would have to test everything properly.
When you run the sample it should use this peace of code.

The next question is how do we get your changes merged with our code?
How many files did you have to change so far?

Rainer


[email protected] wrote:
re: Uprading struts2 extensions to struts 2.1.6

Hello EmpireDB developer team,

i am currently trying to get the empire-db struts extensions running
with struts 2.1.6.
Most of the problems could be solved quite easily, but unfortunately
i
have two issues that i can't solve without doubt.

1. Class: *ItemListTag:130*
    Previously the the method "getId()" was called from the class
"org.apache.struts2.components.Component"
    but this method does no longer exist. By making the nested class
"ItemIteratorComponent" non static, i could get rid
    of the "Cannot make static referenced ..." error, however i am
not
sure if this is a appropriate solution, as thereby the
    method "javax.servlet.jsp.tagext.TagSupport.getId()" will be
called.

2. Classes: *LinkTag:97, AnchorComponent:101*
    The Attribute "targets" as well as the method "setTarges(...)" no
longer exists in *org.apache.struts2.components.Anchor*.
    My current solution for this issue is to remove all references in
all other classes and in the tag library.

I could compile the struts2 extensions and ran the sample application
on
tomcat 6.x with the stated changes (and others).
Could you please help me with the two issues. If you like i can send
you
all the changes i made.

Thanks in advance.

    Benjamin


________________________________________________________________
Neu: WEB.DE Doppel-FLAT mit Internet-Flatrate + Telefon-Flatrate
für nur 19,99 Euro/mtl.!* http://produkte.web.de/go/02/




________________________________________________________________
Neu: WEB.DE Doppel-FLAT mit Internet-Flatrate + Telefon-Flatrate
für nur 19,99 Euro/mtl.!* http://produkte.web.de/go/02/


### Eclipse Workspace Patch 1.0
#P empire-db-struts2
Index: src/main/java/org/apache/empire/struts2/jsp/tags/FormSubmitTag.java
===================================================================
--- src/main/java/org/apache/empire/struts2/jsp/tags/FormSubmitTag.java 
(revision 788067)
+++ src/main/java/org/apache/empire/struts2/jsp/tags/FormSubmitTag.java 
(working copy)
@@ -160,8 +160,14 @@
         {
             return null;
         }
+               
         // Set Name from method
-        String call = (getBoolean(redirect, false) ? "redirect-action:" : 
"action:");
+        /*
+         * UPGRADE-struts 2.1.6
+         * CHANGE: changed "redirect-action" to "redirectAction"
+         * Reason: The types are now written in "camelCase"
+         */
+        String call = (getBoolean(redirect, false) ? "redirectAction:" : 
"action:");
         return call + checkAction(action);
     }
     
Index: src/main/java/org/apache/empire/struts2/action/WebAction.java
===================================================================
--- src/main/java/org/apache/empire/struts2/action/WebAction.java       
(revision 788067)
+++ src/main/java/org/apache/empire/struts2/action/WebAction.java       
(working copy)
@@ -316,6 +316,15 @@
 
     // ------- Text Provider -------
     
+    /*
+     * UPGRADE-struts 2.1.6
+     * CHANGE: added method "asKey(String key)"
+     * Reason: The interface 
com.opensymphony.xwork2.config.entities.Parameterizable changed
+     */
+    public boolean hasKey(String key) {
+       return textProvider.hasKey(key);
+    }
+    
     public String getText(String aTextName) {
         return textProvider.getText(aTextName);
     }
Index: src/main/java/org/apache/empire/struts2/jsp/tags/LinkTag.java
===================================================================
--- src/main/java/org/apache/empire/struts2/jsp/tags/LinkTag.java       
(revision 788067)
+++ src/main/java/org/apache/empire/struts2/jsp/tags/LinkTag.java       
(working copy)
@@ -36,7 +36,12 @@
     protected Object item;
     protected String text;
     protected Object disabled;
-    protected String target;
+    /*
+     * UPGRADE-struts 2.1.6
+     * CHANGE: commented the line "protected String target;"
+     * Reason: the Attribute no longer exists in 
org.apache.struts2.components.Anchor 
+     */
+    //protected String target;
     protected String param;
     protected String onclick;
     protected Object visible;
@@ -57,7 +62,11 @@
         item = null;
         text = null;
         disabled = null;
-        target = null;
+        /*
+                       CHANGE: struts 2.1.6
+               Reason: the Attribute no longer exists in 
org.apache.struts2.components.Anchor 
+       */
+       // target = null;
         param = null;
         onclick = null;
         visible = null;
@@ -94,7 +103,12 @@
         anchor.setAction(action);
         anchor.setText(getString(text));
         anchor.setDisabled(getBoolean(disabled, false));
-        anchor.setTargets(target);
+        /*
+         * UPGRADE-struts 2.1.6
+         * CHANGE: commented the line "anchor.setTargets(target);"
+         * Reason: the Attribute no longer exists in 
org.apache.struts2.components.Anchor 
+         */
+       //anchor.setTargets(target);
         anchor.setOnclick(onclick);
     }
 
@@ -148,11 +162,16 @@
         this.disabled = disabled;
     }
 
-    public void setTarget(String target)
-    {
-        this.target = target;
-    }
-
+    /*
+     * UPGRADE-struts 2.1.6
+     * CHANGE: commented the function "public void setTarget(String target)"
+     * Reason: the Attribute no longer exists in 
org.apache.struts2.components.Anchor 
+     */
+       //public void setTarget(String target)
+    //{
+    //    this.target = target;
+    //}
+       
     public void setParam(String param)
     {
         this.param = param;
Index: 
src/main/java/org/apache/empire/struts2/jsp/components/AnchorComponent.java
===================================================================
--- src/main/java/org/apache/empire/struts2/jsp/components/AnchorComponent.java 
(revision 788067)
+++ src/main/java/org/apache/empire/struts2/jsp/components/AnchorComponent.java 
(working copy)
@@ -98,7 +98,12 @@
                 HtmlTag a = htmlWriter.startTag("a");
                 a.addAttribute("id",       this.getId());
                 a.addAttribute("href",     url);
-                a.addAttribute("target",   this.targets);
+                /*
+                 * UPGRADE-struts 2.1.6
+                 * CHANGE: commented the line " a.addAttribute("target",   
this.targets);"
+                        * Reason: the Attribute no longer exists in 
org.apache.struts2.components.Anchor 
+                       */
+                               // a.addAttribute("target",   this.targets);
                 a.addAttribute("class",    this.cssClass);
                 a.addAttribute("style",    this.cssStyle);
                 a.addAttribute("onclick",  this.onclick);
Index: src/main/java/org/apache/empire/struts2/jsp/tags/ItemListTag.java
===================================================================
--- src/main/java/org/apache/empire/struts2/jsp/tags/ItemListTag.java   
(revision 788067)
+++ src/main/java/org/apache/empire/struts2/jsp/tags/ItemListTag.java   
(working copy)
@@ -127,7 +127,12 @@
                 if (currentValue!=null)
                 {
                     stack.push(currentValue);
-                    String id = getId();
+                                   /*
+                                    * UPGRADE-struts 2.1.6
+                                    * CHANGE: changed "getId()" to "getVar()"
+                                    * Reason: The Funktion no longer exists.
+                                    */
+                    String id = getVar();
 
                     if ((id != null))
                     {
Index: src/main/resources/META-INF/empire-tags.tld
===================================================================
--- src/main/resources/META-INF/empire-tags.tld (revision 788067)
+++ src/main/resources/META-INF/empire-tags.tld (working copy)
@@ -1189,11 +1189,17 @@
       <rtexprvalue>true</rtexprvalue>
          <type>java.lang.Object</type>
     </attribute>
+    <!--
+               * UPGRADE-struts 2.1.6
+               * CHANGE: commented out the "target" attribute
+               * Reason: the Attribute no longer exists in 
org.apache.struts2.components.Anchor 
+       
     <attribute>
       <name>target</name>
       <required>false</required>
       <rtexprvalue>true</rtexprvalue>
     </attribute>
+    -->
     <attribute>
       <name>cssClass</name>
       <required>false</required>
#P empire-db-example-struts2
Index: src/main/webapp/jsp/employeeDetails.jsp
===================================================================
--- src/main/webapp/jsp/employeeDetails.jsp     (revision 788067)
+++ src/main/webapp/jsp/employeeDetails.jsp     (working copy)
@@ -60,9 +60,15 @@
     <e:control column="<%= EMP.C_RETIRED %>" />
        <e:control column="<%= EMP.C_UPDATE_TIMESTAMP %>" />
 
+       
        <%-- 
     <s:submit value="%{getText('button.label.submit')}"/>
-    <s:submit value="%{getText('button.label.cancel')}" 
name="redirect-action:employeeDetail!doCancel"/>
+    <!--
+               * UPGRADE-struts 2.1.6
+               * CHANGE: changed "redirect-action" to "redirectAction"
+               * Reason: The types are now written in "camelCase"
+       -->
+    <s:submit value="%{getText('button.label.cancel')}" 
name="redirectAction:employeeDetail!doCancel"/>
     --%>
        
        <tr style="padding-top:20px">
Index: src/main/webapp/jsp/employeeList.jsp
===================================================================
--- src/main/webapp/jsp/employeeList.jsp        (revision 788067)
+++ src/main/webapp/jsp/employeeList.jsp        (working copy)
@@ -78,6 +78,7 @@
     </e:list>
 </table>
 <p>
+<a target="<%="www.google.de" %>_blank" href="www.google.de">asdf</a>
 <e:link action="!doInit" text="!link.label.search"/>
 </p>
 </body>
Index: src/main/resources/struts.xml
===================================================================
--- src/main/resources/struts.xml       (revision 788067)
+++ src/main/resources/struts.xml       (working copy)
@@ -61,9 +61,14 @@
            <!-- Static Params Interceptor -->
                <action name="login" 
class="org.apache.empire.struts2.websample.web.actions.LoginAction" 
method="doInit">
                        <result name="input">/jsp/login.jsp</result>
-                       <result name="success" 
type="redirect-action">employeeList!doInit</result>
+                       <!--
+                               * UPGRADE-struts 2.1.6
+                               * CHANGE: changed "redirect-action" to 
"redirectAction"
+                       * Reason: The types are now written in "camelCase"
+                       -->
+                       <result name="success" 
type="redirectAction">employeeList!doInit</result>
                </action>
-
+               
                <action name="employeeList" 
class="org.apache.empire.struts2.websample.web.actions.EmployeeListAction" 
method="doInit">
                        <result name="search">/jsp/employeeSearch.jsp</result>
                        <result name="list">/jsp/employeeList.jsp</result>
@@ -71,7 +76,12 @@
 
                <action name="employeeDetail" 
class="org.apache.empire.struts2.websample.web.actions.EmployeeDetailAction" 
method="doLoad">
                        <result name="input">/jsp/employeeDetails.jsp</result>
-                       <result name="return" 
type="redirect-action">employeeList!doList</result>
+                       <!--
+                               * UPGRADE-struts 2.1.6
+                               * CHANGE: changed "redirect-action" to 
"redirectAction"
+                       * Reason: The types are now written in "camelCase"
+                       -->
+                       <result name="return" 
type="redirectAction">employeeList!doList</result>
                </action>
 
        </package>
Index: src/main/webapp/WEB-INF/empire-tags.tld
===================================================================
--- src/main/webapp/WEB-INF/empire-tags.tld     (revision 788067)
+++ src/main/webapp/WEB-INF/empire-tags.tld     (working copy)
@@ -1183,11 +1183,17 @@
       <rtexprvalue>true</rtexprvalue>
          <type>java.lang.Object</type>
     </attribute>
+    <!--
+               * UPGRADE-struts 2.1.6
+               * CHANGE: commented out the "target" attribute
+               * Reason: the Attribute no longer exists in 
org.apache.struts2.components.Anchor 
+       
     <attribute>
       <name>target</name>
       <required>false</required>
       <rtexprvalue>true</rtexprvalue>
     </attribute>
+    -->
     <attribute>
       <name>cssClass</name>
       <required>false</required>
Index: 
src/main/java/org/apache/empire/struts2/websample/web/actions/LoginAction.java
===================================================================
--- 
src/main/java/org/apache/empire/struts2/websample/web/actions/LoginAction.java  
    (revision 788067)
+++ 
src/main/java/org/apache/empire/struts2/websample/web/actions/LoginAction.java  
    (working copy)
@@ -121,9 +121,19 @@
      * Implementation of Parameterizable
      */
      
-    private Map<String, Object> actionConfigParams = null;
+     /*
+      * UPGRADE-struts 2.1.6
+      * CHANGE: changed "Map<String, Object>" to "Map<String, String>"
+      * Reason: The interface 
com.opensymphony.xwork2.config.entities.Parameterizable changed
+      */
+    private Map<String, String> actionConfigParams = null;
     
-    public void addParam(String name, Object value)
+    /*
+     * UPGRADE-struts 2.1.6
+     * CHANGE: changed "String Object" to "String value"
+     * Reason: The interface 
com.opensymphony.xwork2.config.entities.Parameterizable changed
+     */
+    public void addParam(String name, String value)
     {
         actionConfigParams.put(name, value);
     }
@@ -133,7 +143,12 @@
         return actionConfigParams;
     }
 
-    public void setParams(Map<String, Object> actionConfigParams)
+    /*
+     * UPGRADE-struts 2.1.6
+     * CHANGE: changed "Map<String, Object>" to "Map<String, String>"
+     * Reason: The interface 
com.opensymphony.xwork2.config.entities.Parameterizable changed
+     */
+    public void setParams(Map<String, String> actionConfigParams)
     {
         this.actionConfigParams = actionConfigParams; 
     }
#P empire-db-example-struts2-cxf
Index: src/main/webapp/WEB-INF/empire-tags.tld
===================================================================
--- src/main/webapp/WEB-INF/empire-tags.tld     (revision 788067)
+++ src/main/webapp/WEB-INF/empire-tags.tld     (working copy)
@@ -1183,11 +1183,17 @@
       <rtexprvalue>true</rtexprvalue>
          <type>java.lang.Object</type>
     </attribute>
+    <!--
+               * UPGRADE-struts 2.1.6
+               * CHANGE: commented out the "target" attribute
+               * Reason: the Attribute no longer exists in 
org.apache.struts2.components.Anchor 
+       
     <attribute>
       <name>target</name>
       <required>false</required>
       <rtexprvalue>true</rtexprvalue>
     </attribute>
+    -->
     <attribute>
       <name>cssClass</name>
       <required>false</required>
Index: 
src/main/java/org/apache/empire/struts2/websample/web/actions/LoginAction.java
===================================================================
--- 
src/main/java/org/apache/empire/struts2/websample/web/actions/LoginAction.java  
    (revision 788067)
+++ 
src/main/java/org/apache/empire/struts2/websample/web/actions/LoginAction.java  
    (working copy)
@@ -145,22 +145,51 @@
      * Implementation of Parameterizable
      */
 
-    private Map<String, Object> actionConfigParams = null;
+    /*
+     * UPGRADE-struts 2.1.6
+     * CHANGE: changed "Map<String, Object>" to "Map<String, String>"
+     * Reason: The interface 
com.opensymphony.xwork2.config.entities.Parameterizable changed
+     */
+    private Map<String, String> actionConfigParams = null;
 
-    public void addParam(String name, Object value)
+    /*
+     * UPGRADE-struts 2.1.6
+     * CHANGE: changed "String Object" to "String value"
+     * Reason: The interface 
com.opensymphony.xwork2.config.entities.Parameterizable changed
+     */
+    public void addParam(String name, String value)
     {
         actionConfigParams.put(name, value);
     }
 
-    public Map<String, Object> getParams()
+    /*
+     * UPGRADE-struts 2.1.6
+     * CHANGE: changed "Map<String, Object>" to "Map<String, String>"
+     * Reason: The interface 
com.opensymphony.xwork2.config.entities.Parameterizable changed
+     */
+    public Map<String, String> getParams()
     {
         return actionConfigParams;
     }
-
-    public void setParams(Map<String, Object> actionConfigParams)
+       
+    /*
+     * UPGRADE-struts 2.1.6
+     * CHANGE: changed "Map<String, Object>" to "Map<String, String>"
+     * Reason: The interface 
com.opensymphony.xwork2.config.entities.Parameterizable changed
+     */
+    public void setParams(Map<String, String> actionConfigParams)
     {
         this.actionConfigParams = actionConfigParams;
     }
+    
+    /*
+     * UPGRADE-struts 2.1.6
+     * CHANGE: added method "asKey(String key)"
+     * Reason: The interface 
com.opensymphony.xwork2.config.entities.Parameterizable changed
+     */
+    public boolean hasKey(String key) {
+       return this.actionConfigParams.containsKey(key);
+    }
 
     public Options getLanguages()
     {
Index: src/main/resources/struts.xml
===================================================================
--- src/main/resources/struts.xml       (revision 788067)
+++ src/main/resources/struts.xml       (working copy)
@@ -61,7 +61,7 @@
            <!-- Static Params Interceptor -->
                <action name="login" 
class="org.apache.empire.struts2.websample.web.actions.LoginAction" 
method="doInit">
                        <result name="input">/jsp/login.jsp</result>
-                       <result name="success" 
type="redirect-action">employeeList!doInit</result>
+                       <result name="success" 
type="redirectAction">employeeList!doInit</result>
                </action>
 
                <action name="employeeList" 
class="org.apache.empire.struts2.websample.web.actions.EmployeeListAction" 
method="doInit">
@@ -71,7 +71,7 @@
 
                <action name="employeeDetail" 
class="org.apache.empire.struts2.websample.web.actions.EmployeeDetailAction" 
method="doLoad">
                        <result name="input">/jsp/employeeDetails.jsp</result>
-                       <result name="return" 
type="redirect-action">employeeList!doList</result>
+                       <result name="return" 
type="redirectAction">employeeList!doList</result>
                </action>
 
        </package>

Reply via email to