MyFaces Tomahawk
  1. MyFaces Tomahawk
  2. TOMAHAWK-530

imageLocation of inputCalendar does not work

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.1.3
    • Fix Version/s: 1.1.7
    • Component/s: Calendar
    • Labels:
      None

      Description

      Setting e.g. imageLocation="images/calendar" has no effect. Images are still loaded from Extension Filter and not from the URL, which is set in imageLocation.

      1. patch
        2 kB
        Paul Pogonyshev
      2. patch
        1 kB
        Paul Pogonyshev

        Activity

        Hide
        Holger Schimanski added a comment -

        I got a patch by private email from another MyFaces user. Maybe you can use this code to solve this issue.

        In HtmlCalendarRenderer method getLocalizedLanguageScript replace

        StringBuffer script = new StringBuffer();
        setStringVariable(script,popupCalendarVariable
        +".initData.imgDir",(JavascriptUtils.encodeString(AddResourceFactory.getInstance
        (facesContext).getResourceUri(facesContext, HtmlCalendarRenderer.class, "DB/"))));

        by

        StringBuffer script = new StringBuffer();
        String imageLocation = HtmlRendererUtils.getImageLocation(uiComponent);
        if(imageLocation == null)
        setStringVariable(script,popupCalendarVariable +".initData.imgDir",
        (JavascriptUtils.encodeString(AddResourceFactory.getInstance(facesContext)
        .getResourceUri(facesContext, HtmlCalendarRenderer.class, "DB/"))));
        else
        setStringVariable(script, popupCalendarVariable +".initData.imgDir",
        (JavascriptUtils.encodeString(AddResourceFactory.getInstance(facesContext)
        .getResourceUri(facesContext, imageLocation+"/"))) );

        and in getScriptBtn replace

        String imgUrl = (String) uiComponent.getAttributes().get("popupButtonImageUrl");

        if(imgUrl!=null)

        { writer.writeAttribute(HTML.SRC_ATTR, addResource.getResourceUri(facesContext, imgUrl), null); }
        else
        { writer.writeAttribute(HTML.SRC_ATTR, addResource.getResourceUri(facesContext, HtmlCalendarRenderer.class, "images/calendar.gif"), null); }

        by this code

        String imgUrl = (String) uiComponent.getAttributes().get("popupButtonImageUrl");
        String imageLocation = HtmlRendererUtils.getImageLocation(uiComponent);
        if(imgUrl!=null)
        { writer.writeAttribute(HTML.SRC_ATTR, addResource.getResourceUri(facesContext, imgUrl), null); }

        else if (imageLocation != null)

        { writer.writeAttribute(HTML.SRC_ATTR, addResource.getResourceUri(facesContext, imageLocation+"/calendar.gif"), null); }

        else

        { writer.writeAttribute(HTML.SRC_ATTR, addResource.getResourceUri(facesContext, HtmlCalendarRenderer.class, "images/calendar.gif"), null); }
        Show
        Holger Schimanski added a comment - I got a patch by private email from another MyFaces user. Maybe you can use this code to solve this issue. In HtmlCalendarRenderer method getLocalizedLanguageScript replace StringBuffer script = new StringBuffer(); setStringVariable(script,popupCalendarVariable +".initData.imgDir",(JavascriptUtils.encodeString(AddResourceFactory.getInstance (facesContext).getResourceUri(facesContext, HtmlCalendarRenderer.class, "DB/")))); by StringBuffer script = new StringBuffer(); String imageLocation = HtmlRendererUtils.getImageLocation(uiComponent); if(imageLocation == null) setStringVariable(script,popupCalendarVariable +".initData.imgDir", (JavascriptUtils.encodeString(AddResourceFactory.getInstance(facesContext) .getResourceUri(facesContext, HtmlCalendarRenderer.class, "DB/")))); else setStringVariable(script, popupCalendarVariable +".initData.imgDir", (JavascriptUtils.encodeString(AddResourceFactory.getInstance(facesContext) .getResourceUri(facesContext, imageLocation+"/"))) ); and in getScriptBtn replace String imgUrl = (String) uiComponent.getAttributes().get("popupButtonImageUrl"); if(imgUrl!=null) { writer.writeAttribute(HTML.SRC_ATTR, addResource.getResourceUri(facesContext, imgUrl), null); } else { writer.writeAttribute(HTML.SRC_ATTR, addResource.getResourceUri(facesContext, HtmlCalendarRenderer.class, "images/calendar.gif"), null); } by this code String imgUrl = (String) uiComponent.getAttributes().get("popupButtonImageUrl"); String imageLocation = HtmlRendererUtils.getImageLocation(uiComponent); if(imgUrl!=null) { writer.writeAttribute(HTML.SRC_ATTR, addResource.getResourceUri(facesContext, imgUrl), null); } else if (imageLocation != null) { writer.writeAttribute(HTML.SRC_ATTR, addResource.getResourceUri(facesContext, imageLocation+"/calendar.gif"), null); } else { writer.writeAttribute(HTML.SRC_ATTR, addResource.getResourceUri(facesContext, HtmlCalendarRenderer.class, "images/calendar.gif"), null); }
        Hide
        Paul Pogonyshev added a comment -

        Here is the above patch as Subversion diff. Please fix this bug, it makes real customization of appearance impossible.

        Show
        Paul Pogonyshev added a comment - Here is the above patch as Subversion diff. Please fix this bug, it makes real customization of appearance impossible.
        Hide
        Paul Pogonyshev added a comment -

        Sorry, fixed patch.

        Show
        Paul Pogonyshev added a comment - Sorry, fixed patch.
        Hide
        David Van Keer added a comment -

        Supplied patch seems to work nicely. Building a custom jar file for customizing the images of the input calender is somewhat of a big hassle for some most users to do. Would be nice to see this issue resolved in a future release.

        Show
        David Van Keer added a comment - Supplied patch seems to work nicely. Building a custom jar file for customizing the images of the input calender is somewhat of a big hassle for some most users to do. Would be nice to see this issue resolved in a future release.
        Hide
        Grant Smith added a comment -

        Patch applied. Thanks !

        Show
        Grant Smith added a comment - Patch applied. Thanks !

          People

          • Assignee:
            Grant Smith
            Reporter:
            Holger Schimanski
          • Votes:
            6 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development