Issue Details (XML | Word | Printable)

Key: JAVASERVERFACES-2524
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Manfred Riem
Reporter: Andrei Ivanov
Votes: 1
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
javaserverfaces

<c:set> var set with null or empty value

Created: 28/Sep/12 03:03 PM   Updated: 17/Sep/13 02:49 PM   Resolved: 17/Sep/13 02:49 PM
Component/s: None
Affects Version/s: 2.1.13
Fix Version/s: 2.2.4

Time Tracking:
Not Specified

File Attachments: 1. Text File changebundle.txt (6 kB) 17/Sep/13 02:42 PM - Manfred Riem
2. Zip Archive jsf-2524.zip (133 kB) 09/Nov/12 10:11 AM - Andrei Ivanov
3. Zip Archive newfiles.zip (2 kB) 17/Sep/13 02:42 PM - Manfred Riem

Environment:

GlassFish 3.1.2


Tags:
Participants: Andrei Ivanov and Manfred Riem


 Description  « Hide

Trying to upgrade from JSF 1.2 + Facelets to JSF 2, I've noticed this incompatibility:
javax.faces.view.facelets.TagException: /layout/template.xhtml @63,39 <c:set> var set with null or empty value

Searching on Google, I saw that there are some more reports with this issue, but no clear answer on the reason of this change.

From reading this post I got the impression that this should be a valid statement and it should lead to that attribute being removed.

This is the (very reduced) case that I'm trying to solve:

<c:forEach items="#{list}" var="element">
    <c:set var="class" value="" />
    <c:if test="#{some condition}">
        <c:set var="class" value="some-style" />
    </c:if>
    <span class="#{class}">test</span>
</c:forEach>

Please keep in mind that my application is a pretty large one and every small incompatibility with the old versions create a huge amount of work when upgrading.



Manfred Riem added a comment - 08/Nov/12 01:27 PM

Can you please attach an example application (with sources) that demonstrates the problem?


Andrei Ivanov added a comment - 09/Nov/12 10:11 AM

I've attached it.

Running mvn package embedded-glassfish:run should be enough to deploy it.

Use http://localhost:7070


Andrei Ivanov added a comment - 05/Dec/12 09:07 AM

Is there anything else I can help with?


Manfred Riem added a comment - 03/Jan/13 02:16 PM

A patch is always appreciated


Manfred Riem added a comment - 26/Mar/13 07:27 PM

Can you reproduce it with the latest 2.1 release?


Andrei Ivanov added a comment - 28/Mar/13 05:35 PM

Looking at the source from 2.1.20, I still see this in com.sun.faces.facelets.tag.jstl.core.SetHandler

// If var is set, value must be set, otherwise an error is thrown
if (this.var != null && !valSet) {
    throw new TagException(tag, "var set with null or empty value");
}

Andrei Ivanov added a comment - 28/Mar/13 05:38 PM

BTW, I made an attempt to setup an environment to develop the change myself, but I barely made it work with command line and ant and I couldn't import the modules in Eclipse and get it to compile
I think it would have been simpler with a maven build, since Eclipse has decent maven support.


Manfred Riem added a comment - 09/May/13 01:49 PM

Feel free to contribute the changes necessary to make it all Maven projects.


Manfred Riem added a comment - 06/Sep/13 02:46 PM

Can you still reproduce it with the latest 2.1 release?


Andrei Ivanov added a comment - 06/Sep/13 02:51 PM

I did the same code check in SetHandler and the code is unchanged.

In the meantime I've tried Apache MyFaces with success


Manfred Riem added a comment - 17/Sep/13 02:49 PM

Applied to 2.2 branch,

svn commit -m "Fixes https://java.net/jira/browse/JAVASERVERFACES-2524, r=rogerk, make sure c:set can use empty / null values."
Sending jsf-ri\src\main\java\com\sun\faces\facelets\tag\jstl\core\SetHandler.java
Adding test\agnostic\facelets\c\src\main\webapp\setEmpty.xhtml
Adding test\agnostic\facelets\c\src\test\java\com\sun\faces\test\agnostic\facelets\c\Issue2524IT.java
Transmitting file data ...
Committed revision 12550.