Search code examples
javajstlwildflystrutstaglib

Struts 1.x taglibs compatibility issues with jstl tags


I decided to post this question after 3,5 weeks of blocking and i'm really in need of someone's help.

The problem is with the compatibility and coherence of different taglibs, for budget reason we couldn't migrate the IHM and Web framework of the application which is struts 1.2

The problem after my analysis results in incompatibility between struts-nested taglib with it's possible values and jstl tags value.

for example :

The following code doesn't work

            <nested:iterate property="listeSupportsStructuresPlPg">
                <c:choose>
                    <c:when test="${listeSupportsStructuresPlPg.code eq 'PL' && !listeSupportsStructuresPlPg.testOfNajah}">
                        <div class="row">
                            <div class="niveauPLPG">
                                <b>Poche libre </b>
                            </div>
                        </div>
                </c:when>
              </c:choose>
        </nested:iterate>

As you can see the c:when test attribute uses the property listeSupportsStructuresPlPg provided by the nested:iterate tag, when i replace the nested:iterate with c:forEach it works just fine but it crashes later when i wanna do another thing + there are 100s occurences of such code and it will be almost impossible to resolve. it's a very difficult situation i'm facing these times, especially that i have tried everything possible to make this incompatible tags work with each other but no good results was obtained.

Project Context: We were migrating from Web-Logic Server To WilfFly 10.0.0.FINAL, before Migration i'd like to say that this isssue never existed.

Solutions i tried before posting this question

I replaced the local c.tld with

   <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>

I replaced nested:iterate with c:forEach but it didn't work

I replaced strus-nested.tld with many definitions but it didn't work

I upgraded the version from 1.2 to 1.3 until 1.x terminated

I tried to do change the value of the conditions by evaluating booleans instead of lists but it worked only in some places and i couldn't find why.

that's all i can remember, but i can assure you that i tried a lot of possible fixes but no results.


Solution

  • I solved it after a deep analysis guy,

    Here are the steps that i followed so i can make this page work

    Step 1: Changing the way we load the TLDs

    Previously they were loaded locally from WEB-INF folder, i changed it so it can be loaded directly from the appropriate jars.

     <%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean" %>
     <%@ taglib uri="http://struts.apache.org/tags-html" prefix="html" %> 
     <%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic" %>
     <%@ taglib uri="http://struts.apache.org/tags-nested" prefix="nested" %>
     <%@ taglib uri="/WEB-INF/cgit.tld" prefix="cgit" %>
     <%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c" %>
     <%@ taglib uri="http://java.sun.com/jstl/xml" prefix="x" %>
    

    Step 2: Dropping all local TLDs

    Step 3: Struts framework version upgrade

    Previously they core version was at 1.2.8, The current version is 1.3.10

            <dependency>
                <groupId>org.apache.struts</groupId>
                <artifactId>struts-core</artifactId>
                <version>1.3.10</version>
                <optional>true</optional>
            </dependency>
    
    
            <dependency>
                <groupId>org.apache.struts</groupId>
                <artifactId>struts-taglib</artifactId>
                <version>1.3.10</version>
            </dependency>
    
            <dependency>
                <groupId>org.apache.struts</groupId>
                <artifactId>struts-tiles</artifactId>
                <version>1.3.10</version>
            </dependency>
    
            <dependency>
                <groupId>org.apache.struts</groupId>
                <artifactId>struts-tiles</artifactId>
                <version>1.3.10</version>
                <scope>compile</scope>
            </dependency>
    
            <dependency>
                <groupId>org.apache.struts</groupId>
                <artifactId>struts-extras</artifactId>
                <version>1.3.10</version>
            </dependency>
    

    and i changed a little bit the nested:iterate by adding the element id which represents the same thing as var represents in c:forEach

        <nested:iterate id="row" property="listeSupportsStructuresPlPg">
                <c:out value="${row.****}"/>
        </nested:iterate>
    

    This way the jstl c tags can understand the nested:iterate property element.

    Just for information, u skip one if these steps, nothing works

    Thanks for those whom tried to help.