MyFaces Trinidad
  1. MyFaces Trinidad
  2. TRINIDAD-755

Positions of "required" and "message" label should be skinnable

    Details

    • Type: New Feature New Feature
    • Status: Closed
    • Priority: Major Major
    • Resolution: Won't Fix
    • Affects Version/s: 1.0.3-core
    • Fix Version/s: None
    • Component/s: Skinning
    • Labels:
      None

      Description

      Currently Trinidad always shows icon and text of a label in this order: <message-icon> <required-.icon> <text>
      It should be able to specify a different order in the skin.

      1. skin-selectors.patch
        2 kB
        Stephen Friedrich
      2. positions.patch
        39 kB
        Stephen Friedrich

        Activity

        Hide
        Stephen Friedrich added a comment -

        Oh yeah, and an addition to the skin-selector docs.

        Show
        Stephen Friedrich added a comment - Oh yeah, and an addition to the skin-selector docs.
        Hide
        Stephen Friedrich added a comment -

        When I started I hoped for just a few tweaks in the code, but in the end the changes were larger than that:

        • First, if the position of the required icon is skinnable, then the position of the message icon should sure be skinnable, too. Yet, now one must care for the relative ordering in between both icons, too. I solved that by specify the position as an integer index relative to the text position, so -2 for message icon and -1 for required icon is the default, -1 for message and +1 for required would show the message icon in front of and the required icon after the text.
        • There is so much code just to determine whether an icon is shown at all. I need to check that first, to figure out if a   is needed in front of and/or behind the label's text. Most of that code would be needed again if the icon is finally really rendered. To avoid that you can of course remember each icon's details (message type, alt text, ...). Well, to remember it, it makes sense to encapsulate it.
        • If you encapsulate it, you can just as well move icon specific code to the encapsulation class, using it as a delegate from within the renderer. Then it makes sense to move code that is common for both delegates to a base class.
        • Two utility methods that were available from within the renderer at a base class were not accessible from the delegates. I made them static, which is probably ok, because several other methods of the same kind were already static.

        All in all I think the code is more readable now.

        Show
        Stephen Friedrich added a comment - When I started I hoped for just a few tweaks in the code, but in the end the changes were larger than that: First, if the position of the required icon is skinnable, then the position of the message icon should sure be skinnable, too. Yet, now one must care for the relative ordering in between both icons, too. I solved that by specify the position as an integer index relative to the text position, so -2 for message icon and -1 for required icon is the default, -1 for message and +1 for required would show the message icon in front of and the required icon after the text. There is so much code just to determine whether an icon is shown at all. I need to check that first, to figure out if a   is needed in front of and/or behind the label's text. Most of that code would be needed again if the icon is finally really rendered. To avoid that you can of course remember each icon's details (message type, alt text, ...). Well, to remember it, it makes sense to encapsulate it. If you encapsulate it, you can just as well move icon specific code to the encapsulation class, using it as a delegate from within the renderer. Then it makes sense to move code that is common for both delegates to a base class. Two utility methods that were available from within the renderer at a base class were not accessible from the delegates. I made them static, which is probably ok, because several other methods of the same kind were already static. All in all I think the code is more readable now.
        Hide
        Stephen Friedrich added a comment -

        Just in case somebody needs a workaround (well, a dirty hack):
        Include the jquery core, then use

        function fixRequiredIcons() {
        $('.AFRequiredIconStyle').each(function()

        { var e = $(this); var parent = e.parent(); parent.append(' '); e.appendTo(parent); }

        )
        }

        // Needs to re-apply the required icon fix
        TrPage.getInstance().getRequestQueue().addStateChangeListener(pprCallback);

        function pprCallback(status) {
        if (status == TrRequestQueue.STATE_READY)

        { fixRequiredIcons() }

        }

        $(document).ready(function()

        { fixRequiredIcons(); }

        );

        Show
        Stephen Friedrich added a comment - Just in case somebody needs a workaround (well, a dirty hack): Include the jquery core, then use function fixRequiredIcons() { $('.AFRequiredIconStyle').each(function() { var e = $(this); var parent = e.parent(); parent.append(' '); e.appendTo(parent); } ) } // Needs to re-apply the required icon fix TrPage.getInstance().getRequestQueue().addStateChangeListener(pprCallback); function pprCallback(status) { if (status == TrRequestQueue.STATE_READY) { fixRequiredIcons() } } $(document).ready(function() { fixRequiredIcons(); } );
        Hide
        Scott O'Bryan added a comment -

        Version 1.0 is no longer being maintained. If you need this patch, please apply it manually to the trunk-1.0.x branch in trinidad.

        Show
        Scott O'Bryan added a comment - Version 1.0 is no longer being maintained. If you need this patch, please apply it manually to the trunk-1.0.x branch in trinidad.

          People

          • Assignee:
            Scott O'Bryan
            Reporter:
            Stephen Friedrich
          • Votes:
            1 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development