0

I have the following line of code in a JSP File in my web app t

<% if (!maintenance) { %>
<customTag:DialogEntry entry="<%=new com.presentation.generic.session.DialogEntry("dialog1","225px","true","true",new String[]{"authentification.Login.action.logInApplicationLabel"},new String[]{"logInApplication()"}) %>"/>
<% } else { %>
<customTag:DialogEntry entry="<%=new com.presentation.generic.session.DialogEntry("dialog1","225px","true","true",new String[]{},new String[]{}) %>"/>
<% } %>

The error message that I get is:

/WEB-INF/tags/DialogEntry.tag According to the TLD , the value attribute accepts no expression

How do I resolve this problem?

DialogEntry.tag:

<%@ attribute name="entry" rtexprvalue="true" type="com.presentation.generic.session.DialogEntry" %>

<%@ taglib uri="http://struts.apache.org/tags-tiles" prefix="tiles" %>
<%@ taglib uri="http://struts.apache.org/tags-html-el" prefix="html" %>
<%@ taglib uri="http://struts.apache.org/tags-bean-el" prefix="bean" %>
<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %>
<%@ taglib uri="http://struts.apache.org/tags-logic-el" prefix="logic" %>




    <script type="text/javascript">

    //confirm("<c:out value="${entry.id}" /> début");

    var <c:out value="${entry.id}" /> = new YAHOO.widget.Dialog("<c:out value="${entry.id}" />", 
            { 
        width: "<c:out value="${entry.size}" />", 
        <c:if test="${\"\" != entry.visible}">
            visible:true,
        </c:if>
        <c:if test="${\"\" == entry.visible}">
            visible:false,
        </c:if>


        close:false,
        draggable :false
        <c:if test="${\"\" != entry.effect}">
            ,effect:{effect:YAHOO.widget.ContainerEffect.FADE,duration:0.5} 
                        } ); 
        </c:if>
        <c:if test="${\"\" == entry.effect}">
            } );
        </c:if>

        <c:if test="${\"false\" != entry.hasButtons}">

            var myButtons = [  
            <c:forEach var="button" items="${entry.buttons}" varStatus="ind">
                    { text:"<bean:message key="${button}"/>", handler:function() {<c:out value="${entry.functions[ind.index]}" />;}, isDefault:true }
                     <c:if test="${!empty entry.buttons[ind.index+1]}">
                        ,
                    </c:if>
            </c:forEach>
            ];

            <c:out value="${entry.id}" />.cfg.queueProperty("buttons", myButtons);
        </c:if>

    // confirm("<c:out value="${entry.id}" /> fin - debut script");

    if($.browser.msie && $('#header').size() > 0 ){

        // confirm("<c:out value="${entry.id}" /> fin - debut script IE");
        var menuWidth = $("div#menu").get(0).clientWidth;

        var headerHeight = $("div#header").get(0).clientHeight;

        var width = document.body.clientWidth;
        var contentWidthConnected = width - menuWidth;

        if( $('div#content_onglets').size() > 0){
            // confirm("<c:out value="${entry.id}" /> fin - debut script IE Onglet");
            <c:out value="${entry.id}" />.cfg.queueProperty("x", 50);
            <c:out value="${entry.id}" />.cfg.queueProperty("y", 0);

        }
        else{
            // confirm("<c:out value="${entry.id}" /> fin - debut script IE Pas Onglet");
            <c:out value="${entry.id}" />.cfg.queueProperty("x", menuWidth + 50);
            <c:out value="${entry.id}" />.cfg.queueProperty("y", headerHeight );
        }

        // confirm("<c:out value="${entry.id}" /> fin - FIN script IE");

    }
    else{
        <c:out value="${entry.id}" />.cfg.queueProperty("fixedcenter", true);
    }       

    // confirm("<c:out value="${entry.id}" /> fin script");

    <c:out value="${entry.id}" />.render();



    // confirm("<c:out value="${entry.id}" /> fin script 2");
    </script>
Mercer
  • 9,736
  • 30
  • 105
  • 170
  • @Satya i'm sorry i don't understand – Mercer Jan 22 '16 at 13:39
  • 1
    instead of using double quotes outside try with single quotes. – SatyaTNV Jan 22 '16 at 13:40
  • You've totally changed the question. You should have accepted one of the answers that solved the question you asked, and opened a new one for your new problem. – Mike Harris Jan 22 '16 at 14:10
  • @MikeHarris ok , i valid this question – Mercer Jan 22 '16 at 14:12
  • You're missing the point. You asked a question, you got an answer that solved your question, then you edited the question so that it's asking a totally different question. This doesn't help anyone who comes to this site with the same problem. – Mike Harris Jan 22 '16 at 14:19

2 Answers2

2

Either escape your inner quotes:

<% if (!maintenance) { %>
    <customTag:DialogEntry entry="<%=new com.presentation.generic.session.DialogEntry(\"dialog1\",\"225px\",\"true\",\"true\",new String[]{\"authentification.Login.action.logInApplicationLabel\"},new String[]{\"logInApplication()\"}) %>"/>
<% } else { %>
    <customTag:DialogEntry entry="<%=new com.presentation.generic.session.DialogEntry(\"dialog1\",\"225px\",\"true\",\"true\",new String[]{},new String[]{}) %>"/>
<% } %>

Or use single quotes:

<% if (!maintenance) { %>
    <customTag:DialogEntry entry='<%=new com.presentation.generic.session.DialogEntry("dialog1","225px","true","true",new String[]{"authentification.Login.action.logInApplicationLabel"},new String[]{"logInApplication()"}) %>'/>
<% } else { %>
    <customTag:DialogEntry entry='<%=new com.presentation.generic.session.DialogEntry("dialog1","225px","true","true",new String[]{},new String[]{}) %>'/>
<% } %>

Reading the error message is quoted with " which must be escaped when used within the value you see that having " inside your text is the cause. Hence, either your text is not defined with " (the second solution, where you use ') or the " inside the text have a \ to escape them and make them actual characters in the text.

BlueMoon93
  • 2,910
  • 22
  • 39
  • when i do your solution i have this message `/WEB-INF/tags/DialogEntry.tag According to the TLD , the value attribute accepts no expression.` – Mercer Jan 22 '16 at 13:45
  • 1
    That's some other issue in your code that I've no idea about. Maybe open a new question or edit this one? – BlueMoon93 Jan 22 '16 at 13:47
  • i add my `DialogEntry.tag` source – Mercer Jan 22 '16 at 13:48
  • I'm not a JSP expert. Either make a new question or wait until someone can help. I'd advise adding the editions, new error, and maybe a new title, to this question if you're not creating a new one. – BlueMoon93 Jan 22 '16 at 13:54
1

Escape all " with \" inside your block:

entry=""
eg04lt3r
  • 2,467
  • 14
  • 19