Uploaded image for project: 'MyFaces Tomahawk'
  1. MyFaces Tomahawk
  2. TOMAHAWK-269

JSCookMenu can't be used as a child of a form, and AddResources code for custom themes is incomplete

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 1.1.2
    • JS Cook Menu
    • None

    Description

      As is stated as a known todo in HtmlJSCookMenuRenderer, the menu can not be the child of a form because it currently hard-codes in the form name to change. To fix this, the renderer must examine it's parental chain to see if there is a form. If so, it needs to get the clientId of the form and use that instead of linkDummyForm.

      The second portion of this bug is that the AddResources code, specifically, the code in 'addThemeSpecificResources()' is incomplete/buggy. It checks to see if the theme name is set to determine if it is one of the pre-defined ones. However, even if you specify a javascriptlocation, you still must have a theme name set. To fix this, instead of seeing if theme name is set (which it always will, as it's a required tag attribute), the renderer should see if javascriptLocation is NOT set, before checking theme name for one of the pre-defined themes. This allows those of us with custom themes that want to use addResources to add them dynamically, to do so by specifying the javascriptLocation, styleLocation and imageLocation.

      Here's a sample usage of the javascriptLocation, styleLocation, imageLocation as I've fixed it:

      <h:form>
      <t:jscookMenu layout="hbr" theme="ActionBar"
      javascriptLocation="/jscookmenu/"
      imageLocation="/jscookmenu/"
      styleLocation="/jscookmenu/">
      <t:navigationMenuItem id="add_attachment" icon="/images/addAttachment.gif" itemLabel="Add Attachment" action="#

      {noteBean.addAttachment}

      " />
      <t:navigationMenuItem id="delete" icon="/images/delete.gif" itemLabel="Delete" action="#

      {noteBean.delete}

      " />
      </t:jscookMenu>
      </h:form>

      Note that I've made my own copy of the jscookmenu scripts in /jscookmenu/, and my theme, ActionBar, is also under the /jscookmenu/ folder.

      As an enhancement, it would be nice if the jscookmenu allowed a generic 'scriptLocation' element which would be used for all three, javascriptLocation, imageLocation, styleLocation.

      I will attach the patch that fixes these items.

      Attachments

        1. jscookFormPatchV4.txt
          8 kB
          Neal Haggard
        2. jscookFormPatchV5.txt
          13 kB
          Neal Haggard

        Activity

          People

            mmarinschek Martin Marinschek
            morgenes Neal Haggard
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: