javaserverfaces
  1. javaserverfaces
  2. JAVASERVERFACES-55

commandButton image attr don't add context path

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Blocker Blocker
    • Resolution: Fixed
    • Affects Version/s: current
    • Fix Version/s: 1.2
    • Component/s: None
    • Labels:
      None
    • Environment:

      Operating System: All
      Platform: All

    • Issuezilla Id:
      55

      Description

      If I use image attribute of commandButton JSF RI don't add application context
      path to the image url if it starts with /.
      Therefore images can't be found if my application has some context path.

        Activity

        Hide
        a_ilyin added a comment -

        Created an attachment (id=30)
        This patch resolve this issue. Just apply it. I add src method to ButtonRenderer similar to ImageRenderer one.

        Show
        a_ilyin added a comment - Created an attachment (id=30) This patch resolve this issue. Just apply it. I add src method to ButtonRenderer similar to ImageRenderer one.
        Hide
        jayashri added a comment -

        Thanks for the patch. Since this involves a spec clarification, its filed as an
        EG issue here
        https://javaserverfaces-spec-public.dev.java.net/issues/show_bug.cgi?id=30

        Once EG approves this change, I will commit your patch.
        Thanks
        -Jayashri

        Show
        jayashri added a comment - Thanks for the patch. Since this involves a spec clarification, its filed as an EG issue here https://javaserverfaces-spec-public.dev.java.net/issues/show_bug.cgi?id=30 Once EG approves this change, I will commit your patch. Thanks -Jayashri
        Hide
        jayashri added a comment -

        Issue targeted for JSF 1.2

        Show
        jayashri added a comment - Issue targeted for JSF 1.2
        Hide
        jayashri added a comment -

        Taking ownership

        Show
        jayashri added a comment - Taking ownership
        Hide
        jayashri added a comment -

        Patch Applied, Thanks a_ilyin.

        M src/com/sun/faces/renderkit/html_basic/ButtonRenderer.java
        Apply the patch from a_ilyin. If the image src attribute starts "/"
        prepend context path.

        M web/test/RenderResponse_correct
        M web/test/TestRenderResponsePhase.jsp
        updated test and golden files.

        Index: src/com/sun/faces/renderkit/html_basic/ButtonRenderer.java
        ===================================================================
        RCS file:
        /cvs/javaserverfaces-sources/jsf-ri/src/com/sun/faces/renderkit/html_basic/ButtonRenderer.java,v
        retrieving revision 1.81
        diff -u -r1.81 ButtonRenderer.java
        — src/com/sun/faces/renderkit/html_basic/ButtonRenderer.java 16 Dec 2004
        17:56:36 -0000 1.81
        +++ src/com/sun/faces/renderkit/html_basic/ButtonRenderer.java 18 Mar 2005
        23:48:34 -0000
        @@ -162,9 +162,8 @@
        String clientId = component.getClientId(context);
        if (imageSrc != null)

        { writer.writeAttribute("type", "image", "type"); - writer.writeURIAttribute("src", imageSrc, "image"); - writer.writeAttribute("name", clientId, - "clientId"); + writer.writeURIAttribute("src", src(context, imageSrc), "image"); + writer.writeAttribute("name", clientId, "clientId"); }

        else {
        writer.writeAttribute("type", type.toLowerCase(), "type");
        writer.writeAttribute("name", clientId, "clientId");
        @@ -229,6 +228,15 @@
        //
        // General Methods
        //
        +
        + private String src(FacesContext context, String value) {
        + if (value == null)

        { + return ""; + }

        + value = context.getApplication().getViewHandler().
        + getResourceURL(context, value);
        + return (context.getExternalContext().encodeResourceURL(value));
        + }

        } // end of class ButtonRenderer
        Index: web/test/RenderResponse_correct
        ===================================================================
        RCS file: /cvs/javaserverfaces-sources/jsf-ri/web/test/RenderResponse_correct,v
        retrieving revision 1.120
        diff -u -r1.120 RenderResponse_correct
        — web/test/RenderResponse_correct 18 Mar 2005 20:10:16 -0000 1.120
        +++ web/test/RenderResponse_correct 18 Mar 2005 23:48:35 -0000
        @@ -15,7 +15,7 @@

        -<form id="basicForm" method="post"
        action="/test/faces/TestRenderResponsePhase.jsp;jsessionid=95F83ADE9D04C306D880389D1992A343"
        class="formClass" accept-charset="some-charset" accept="html,wml"
        enctype="application/x-www-form-urlencoded" target="_self" title="basicForm">
        +<form id="basicForm" method="post"
        action="/test/faces/TestRenderResponsePhase.jsp;jsessionid=9812049625FB03B5F31EB569F0830E84"
        class="formClass" accept-charset="some-charset" accept="html,wml"
        enctype="application/x-www-form-urlencoded" target="_self" title="basicForm">

        <TABLE BORDER="1">
        @@ -74,7 +74,7 @@

        <TD>

        • <input id="basicForm:pushButton" type="image" src="duke.gif"
          name="basicForm:pushButton"
          onclick="clearFormHiddenParams_basicForm(this.form.id);" style="someStyle"
          disabled="disabled" />
          + <input id="basicForm:pushButton" type="image"
          src="duke.gif;jsessionid=9812049625FB03B5F31EB569F0830E84"
          name="basicForm:pushButton"
          onclick="clearFormHiddenParams_basicForm(this.form.id);" style="someStyle"
          disabled="disabled" />

        </TD>

        @@ -85,7 +85,7 @@

        <TD>

        • <input id="basicForm:imageOnlyButton" type="image" src="duke.gif"
          name="basicForm:imageOnlyButton"
          onclick="clearFormHiddenParams_basicForm(this.form.id);" />
          + <input id="basicForm:imageOnlyButton" type="image"
          src="/test/duke.gif;jsessionid=9812049625FB03B5F31EB569F0830E84"
          name="basicForm:imageOnlyButton"
          onclick="clearFormHiddenParams_basicForm(this.form.id);" />

        </TD>

        @@ -130,12 +130,12 @@

        • <a id="basicForm:imageLink" href="#" style="someStyle"
          onclick="clearFormHiddenParams_basicForm('basicForm');document.forms['basicForm']['basicForm:_idcl'].value='basicForm:imageLink';
          document.forms['basicForm'].submit(); return false;"><img
          src="duke.gif;jsessionid=95F83ADE9D04C306D880389D1992A343" /></a>
          + <a id="basicForm:imageLink" href="#" style="someStyle"
          onclick="clearFormHiddenParams_basicForm('basicForm');document.forms['basicForm']['basicForm:_idcl'].value='basicForm:imageLink';
          document.forms['basicForm'].submit(); return false;"><img
          src="duke.gif;jsessionid=9812049625FB03B5F31EB569F0830E84" /></a>

        </TD>

        <TD>

        • <img id="basicForm:graphicImage"
          src="/test/duke.gif;jsessionid=95F83ADE9D04C306D880389D1992A343"
          style="someStyle" usemap="#map1" ismap="ismap" />
          + <img id="basicForm:graphicImage"
          src="/test/duke.gif;jsessionid=9812049625FB03B5F31EB569F0830E84"
          style="someStyle" usemap="#map1" ismap="ismap" />
          </TD>

        </TR>
        @@ -169,7 +169,7 @@

        • <a id="basicForm:hrefParamLink" href="#"
          onclick="clearFormHiddenParams_basicForm('basicForm');document.forms['basicForm']['basicForm:_idcl'].value='basicForm:hrefParamLink';document.forms['basicForm']['name'].value='horwat';document.forms['basicForm']['value'].value='password';
          document.forms['basicForm'].target='_top'; document.forms['basicForm'].submit();
          return false;"><img src="duke.gif;jsessionid=95F83ADE9D04C306D880389D1992A343"
          /></a>
          + <a id="basicForm:hrefParamLink" href="#"
          onclick="clearFormHiddenParams_basicForm('basicForm');document.forms['basicForm']['basicForm:_idcl'].value='basicForm:hrefParamLink';document.forms['basicForm']['name'].value='horwat';document.forms['basicForm']['value'].value='password';
          document.forms['basicForm'].target='_top'; document.forms['basicForm'].submit();
          return false;"><img src="duke.gif;jsessionid=9812049625FB03B5F31EB569F0830E84"
          /></a>
          </TD>
          </TR>

        @@ -177,7 +177,7 @@

        <TD>

        • <a id="basicForm:outputLink"
          href="test.html;jsessionid=95F83ADE9D04C306D880389D1992A343"
          class="hyperlinkClass">output link text</a>
          + <a id="basicForm:outputLink"
          href="test.html;jsessionid=9812049625FB03B5F31EB569F0830E84"
          class="hyperlinkClass">output link text</a>

        </TD>

        @@ -189,12 +189,12 @@

        • <a id="basicForm:output_imageLink"
          href="test.html;jsessionid=95F83ADE9D04C306D880389D1992A343" style="position:
          absolute; left: 96px; top: 168px"><img
          src="duke.gif;jsessionid=95F83ADE9D04C306D880389D1992A343" /></a>
          + <a id="basicForm:output_imageLink"
          href="test.html;jsessionid=9812049625FB03B5F31EB569F0830E84" style="position:
          absolute; left: 96px; top: 168px"><img
          src="duke.gif;jsessionid=9812049625FB03B5F31EB569F0830E84" /></a>

        </TD>

        <TD>

        • <img id="basicForm:output_graphicImage"
          src="/test/duke.gif;jsessionid=95F83ADE9D04C306D880389D1992A343" usemap="#map1"
          ismap="ismap" />
          + <img id="basicForm:output_graphicImage"
          src="/test/duke.gif;jsessionid=9812049625FB03B5F31EB569F0830E84" usemap="#map1"
          ismap="ismap" />
          </TD>

        </TR>
        @@ -202,7 +202,7 @@
        <TR>
        <TD>

        • <a id="basicForm:output_commandLink"
          href="test.html;jsessionid=95F83ADE9D04C306D880389D1992A343" style="position:
          absolute; left: 96px; top: 168px" class="hyperlinkClass">link text</a>
          + <a id="basicForm:output_commandLink"
          href="test.html;jsessionid=9812049625FB03B5F31EB569F0830E84" style="position:
          absolute; left: 96px; top: 168px" class="hyperlinkClass">link text</a>
          </TD>
          </TR>

        @@ -212,13 +212,13 @@

        • <a id="basicForm:output_commandParamLink"
          href="test.html;jsessionid=95F83ADE9D04C306D880389D1992A343?name=horwat&value=password"
          class="hyperlinkClass">link text</a>
          + <a id="basicForm:output_commandParamLink"
          href="test.html;jsessionid=9812049625FB03B5F31EB569F0830E84?name=horwat&value=password"
          class="hyperlinkClass">link text</a>
          </TD>
          </TR>

        <TR>
        <TD>

        • <a id="basicForm:output_hrefLink"
          href="test.html;jsessionid=95F83ADE9D04C306D880389D1992A343"><img
          src="duke.gif"></a>
          + <a id="basicForm:output_hrefLink"
          href="test.html;jsessionid=9812049625FB03B5F31EB569F0830E84"><img
          src="duke.gif"></a>
          </TD>
          </TR>

        @@ -228,7 +228,7 @@

        • <a id="basicForm:output_hrefParamLink"
          href="test.html;jsessionid=95F83ADE9D04C306D880389D1992A343?name=horwat&value=password"><img
          src="duke.gif;jsessionid=95F83ADE9D04C306D880389D1992A343" /></a>
          + <a id="basicForm:output_hrefParamLink"
          href="test.html;jsessionid=9812049625FB03B5F31EB569F0830E84?name=horwat&value=password"><img
          src="duke.gif;jsessionid=9812049625FB03B5F31EB569F0830E84" /></a>
          </TD>
          </TR>

        Index: web/test/TestRenderResponsePhase.jsp
        ===================================================================
        RCS file: /cvs/javaserverfaces-sources/jsf-ri/web/test/TestRenderResponsePhase.jsp,v
        retrieving revision 1.88
        diff -u -r1.88 TestRenderResponsePhase.jsp
        — web/test/TestRenderResponsePhase.jsp 18 Mar 2005 20:10:16 -0000 1.88
        +++ web/test/TestRenderResponsePhase.jsp 18 Mar 2005 23:48:35 -0000
        @@ -73,7 +73,7 @@
        <TD>

        <h:commandButton id="imageOnlyButton" type="submit"

        • image="duke.gif" rendered="true">
          + image="/duke.gif" rendered="true">
          </h:commandButton>
          </TD>
        Show
        jayashri added a comment - Patch Applied, Thanks a_ilyin. M src/com/sun/faces/renderkit/html_basic/ButtonRenderer.java Apply the patch from a_ilyin. If the image src attribute starts "/" prepend context path. M web/test/RenderResponse_correct M web/test/TestRenderResponsePhase.jsp updated test and golden files. Index: src/com/sun/faces/renderkit/html_basic/ButtonRenderer.java =================================================================== RCS file: /cvs/javaserverfaces-sources/jsf-ri/src/com/sun/faces/renderkit/html_basic/ButtonRenderer.java,v retrieving revision 1.81 diff -u -r1.81 ButtonRenderer.java — src/com/sun/faces/renderkit/html_basic/ButtonRenderer.java 16 Dec 2004 17:56:36 -0000 1.81 +++ src/com/sun/faces/renderkit/html_basic/ButtonRenderer.java 18 Mar 2005 23:48:34 -0000 @@ -162,9 +162,8 @@ String clientId = component.getClientId(context); if (imageSrc != null) { writer.writeAttribute("type", "image", "type"); - writer.writeURIAttribute("src", imageSrc, "image"); - writer.writeAttribute("name", clientId, - "clientId"); + writer.writeURIAttribute("src", src(context, imageSrc), "image"); + writer.writeAttribute("name", clientId, "clientId"); } else { writer.writeAttribute("type", type.toLowerCase(), "type"); writer.writeAttribute("name", clientId, "clientId"); @@ -229,6 +228,15 @@ // // General Methods // + + private String src(FacesContext context, String value) { + if (value == null) { + return ""; + } + value = context.getApplication().getViewHandler(). + getResourceURL(context, value); + return (context.getExternalContext().encodeResourceURL(value)); + } } // end of class ButtonRenderer Index: web/test/RenderResponse_correct =================================================================== RCS file: /cvs/javaserverfaces-sources/jsf-ri/web/test/RenderResponse_correct,v retrieving revision 1.120 diff -u -r1.120 RenderResponse_correct — web/test/RenderResponse_correct 18 Mar 2005 20:10:16 -0000 1.120 +++ web/test/RenderResponse_correct 18 Mar 2005 23:48:35 -0000 @@ -15,7 +15,7 @@ -<form id="basicForm" method="post" action="/test/faces/TestRenderResponsePhase.jsp;jsessionid=95F83ADE9D04C306D880389D1992A343" class="formClass" accept-charset="some-charset" accept="html,wml" enctype="application/x-www-form-urlencoded" target="_self" title="basicForm"> +<form id="basicForm" method="post" action="/test/faces/TestRenderResponsePhase.jsp;jsessionid=9812049625FB03B5F31EB569F0830E84" class="formClass" accept-charset="some-charset" accept="html,wml" enctype="application/x-www-form-urlencoded" target="_self" title="basicForm"> <TABLE BORDER="1"> @@ -74,7 +74,7 @@ <TD> <input id="basicForm:pushButton" type="image" src="duke.gif" name="basicForm:pushButton" onclick="clearFormHiddenParams_basicForm(this.form.id);" style="someStyle" disabled="disabled" /> + <input id="basicForm:pushButton" type="image" src="duke.gif;jsessionid=9812049625FB03B5F31EB569F0830E84" name="basicForm:pushButton" onclick="clearFormHiddenParams_basicForm(this.form.id);" style="someStyle" disabled="disabled" /> </TD> @@ -85,7 +85,7 @@ <TD> <input id="basicForm:imageOnlyButton" type="image" src="duke.gif" name="basicForm:imageOnlyButton" onclick="clearFormHiddenParams_basicForm(this.form.id);" /> + <input id="basicForm:imageOnlyButton" type="image" src="/test/duke.gif;jsessionid=9812049625FB03B5F31EB569F0830E84" name="basicForm:imageOnlyButton" onclick="clearFormHiddenParams_basicForm(this.form.id);" /> </TD> @@ -130,12 +130,12 @@ <a id="basicForm:imageLink" href="#" style="someStyle" onclick="clearFormHiddenParams_basicForm('basicForm');document.forms ['basicForm'] ['basicForm:_idcl'] .value='basicForm:imageLink'; document.forms ['basicForm'] .submit(); return false;"><img src="duke.gif;jsessionid=95F83ADE9D04C306D880389D1992A343" /></a> + <a id="basicForm:imageLink" href="#" style="someStyle" onclick="clearFormHiddenParams_basicForm('basicForm');document.forms ['basicForm'] ['basicForm:_idcl'] .value='basicForm:imageLink'; document.forms ['basicForm'] .submit(); return false;"><img src="duke.gif;jsessionid=9812049625FB03B5F31EB569F0830E84" /></a> </TD> <TD> <img id="basicForm:graphicImage" src="/test/duke.gif;jsessionid=95F83ADE9D04C306D880389D1992A343" style="someStyle" usemap="#map1" ismap="ismap" /> + <img id="basicForm:graphicImage" src="/test/duke.gif;jsessionid=9812049625FB03B5F31EB569F0830E84" style="someStyle" usemap="#map1" ismap="ismap" /> </TD> </TR> @@ -169,7 +169,7 @@ <a id="basicForm:hrefParamLink" href="#" onclick="clearFormHiddenParams_basicForm('basicForm');document.forms ['basicForm'] ['basicForm:_idcl'] .value='basicForm:hrefParamLink';document.forms ['basicForm'] ['name'] .value='horwat';document.forms ['basicForm'] ['value'] .value='password'; document.forms ['basicForm'] .target='_top'; document.forms ['basicForm'] .submit(); return false;"><img src="duke.gif;jsessionid=95F83ADE9D04C306D880389D1992A343" /></a> + <a id="basicForm:hrefParamLink" href="#" onclick="clearFormHiddenParams_basicForm('basicForm');document.forms ['basicForm'] ['basicForm:_idcl'] .value='basicForm:hrefParamLink';document.forms ['basicForm'] ['name'] .value='horwat';document.forms ['basicForm'] ['value'] .value='password'; document.forms ['basicForm'] .target='_top'; document.forms ['basicForm'] .submit(); return false;"><img src="duke.gif;jsessionid=9812049625FB03B5F31EB569F0830E84" /></a> </TD> </TR> @@ -177,7 +177,7 @@ <TD> <a id="basicForm:outputLink" href="test.html;jsessionid=95F83ADE9D04C306D880389D1992A343" class="hyperlinkClass">output link text</a> + <a id="basicForm:outputLink" href="test.html;jsessionid=9812049625FB03B5F31EB569F0830E84" class="hyperlinkClass">output link text</a> </TD> @@ -189,12 +189,12 @@ <a id="basicForm:output_imageLink" href="test.html;jsessionid=95F83ADE9D04C306D880389D1992A343" style="position: absolute; left: 96px; top: 168px"><img src="duke.gif;jsessionid=95F83ADE9D04C306D880389D1992A343" /></a> + <a id="basicForm:output_imageLink" href="test.html;jsessionid=9812049625FB03B5F31EB569F0830E84" style="position: absolute; left: 96px; top: 168px"><img src="duke.gif;jsessionid=9812049625FB03B5F31EB569F0830E84" /></a> </TD> <TD> <img id="basicForm:output_graphicImage" src="/test/duke.gif;jsessionid=95F83ADE9D04C306D880389D1992A343" usemap="#map1" ismap="ismap" /> + <img id="basicForm:output_graphicImage" src="/test/duke.gif;jsessionid=9812049625FB03B5F31EB569F0830E84" usemap="#map1" ismap="ismap" /> </TD> </TR> @@ -202,7 +202,7 @@ <TR> <TD> <a id="basicForm:output_commandLink" href="test.html;jsessionid=95F83ADE9D04C306D880389D1992A343" style="position: absolute; left: 96px; top: 168px" class="hyperlinkClass">link text</a> + <a id="basicForm:output_commandLink" href="test.html;jsessionid=9812049625FB03B5F31EB569F0830E84" style="position: absolute; left: 96px; top: 168px" class="hyperlinkClass">link text</a> </TD> </TR> @@ -212,13 +212,13 @@ <a id="basicForm:output_commandParamLink" href="test.html;jsessionid=95F83ADE9D04C306D880389D1992A343?name=horwat&value=password" class="hyperlinkClass">link text</a> + <a id="basicForm:output_commandParamLink" href="test.html;jsessionid=9812049625FB03B5F31EB569F0830E84?name=horwat&value=password" class="hyperlinkClass">link text</a> </TD> </TR> <TR> <TD> <a id="basicForm:output_hrefLink" href="test.html;jsessionid=95F83ADE9D04C306D880389D1992A343"><img src="duke.gif"></a> + <a id="basicForm:output_hrefLink" href="test.html;jsessionid=9812049625FB03B5F31EB569F0830E84"><img src="duke.gif"></a> </TD> </TR> @@ -228,7 +228,7 @@ <a id="basicForm:output_hrefParamLink" href="test.html;jsessionid=95F83ADE9D04C306D880389D1992A343?name=horwat&value=password"><img src="duke.gif;jsessionid=95F83ADE9D04C306D880389D1992A343" /></a> + <a id="basicForm:output_hrefParamLink" href="test.html;jsessionid=9812049625FB03B5F31EB569F0830E84?name=horwat&value=password"><img src="duke.gif;jsessionid=9812049625FB03B5F31EB569F0830E84" /></a> </TD> </TR> Index: web/test/TestRenderResponsePhase.jsp =================================================================== RCS file: /cvs/javaserverfaces-sources/jsf-ri/web/test/TestRenderResponsePhase.jsp,v retrieving revision 1.88 diff -u -r1.88 TestRenderResponsePhase.jsp — web/test/TestRenderResponsePhase.jsp 18 Mar 2005 20:10:16 -0000 1.88 +++ web/test/TestRenderResponsePhase.jsp 18 Mar 2005 23:48:35 -0000 @@ -73,7 +73,7 @@ <TD> <h:commandButton id="imageOnlyButton" type="submit" image="duke.gif" rendered="true"> + image="/duke.gif" rendered="true"> </h:commandButton> </TD>
        Hide
        jayashri added a comment -

        r=edburns. Fix checked in

        Show
        jayashri added a comment - r=edburns. Fix checked in
        Hide
        Manfred Riem added a comment -

        Closing issue out

        Show
        Manfred Riem added a comment - Closing issue out

          People

          • Assignee:
            jayashri
            Reporter:
            a_ilyin
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: