Details

    • Type: New Feature New Feature
    • Status: Resolved
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 1.3.2
    • Fix Version/s: 1.4.18, 1.5-RC6
    • Component/s: wicket
    • Labels:
      None

      Description

      This often happens during my daily work:

      You create a form with labels and corresponding input fields. As it is now, you have to bind all those Labels and FormComponents together with some "boilerplate" code within Java.

      I'd like to suggest the following enhancement Wicket tag:

      <label wicket:for="username" wicket:messge="key">default message</label>

      where wicket:for contains the referenced wicket:id

        Activity

        Igor Vaynberg made changes -
        Status Open [ 1 ] Resolved [ 5 ]
        Fix Version/s 1.4.18 [ 12316329 ]
        Fix Version/s 1.5-RC6 [ 12316657 ]
        Resolution Fixed [ 1 ]
        Igor Vaynberg made changes -
        Assignee Igor Vaynberg [ ivaynberg ]
        Martin Grigorov made changes -
        Fix Version/s 1.5-M4 [ 12315483 ]
        Jeremy Thomerson made changes -
        Fix Version/s 1.5-M4 [ 12315483 ]
        Fix Version/s 1.5-M3 [ 12315329 ]
        Igor Vaynberg made changes -
        Fix Version/s 1.5-M3 [ 12315329 ]
        Fix Version/s 1.5-M2 [ 12315237 ]
        Igor Vaynberg made changes -
        Fix Version/s 1.5-M2 [ 12315237 ]
        Fix Version/s 1.5-M1 [ 12313078 ]
        Hide
        robert mcguinness added a comment -

        I made some modifications for our use case, maybe others would be interested. Renders a required "*" for the labels.

        public boolean resolve(MarkupContainer container, MarkupStream markupStream, ComponentTag tag) {
        // make sure any raw markup with wicket:for attrs is a component

        if (WICKET_FOR_CONTAINER_ID.equals(tag.getId())) {
        Component wc;
        if (tag.isOpenClose())

        { wc = new WebComponent(WICKET_FOR_CONTAINER_ID + container.getPage().getAutoIndex()); }

        else

        { wc = new TransparentContainer(WICKET_FOR_CONTAINER_ID + container.getPage().getAutoIndex()); }

        String refId = tag.getAttributes().getString(WICKET_FOR_ATTRIBUTE_NAME);
        if (!Strings.isEmpty(refId)) {
        refId = refId.trim();

        // Find the referred sibling component by id.
        Component refComponent = container.getParent().get(refId);

        if (refComponent instanceof FormComponent<?>) {
        FormComponent<?> formComponent = (FormComponent<?>) refComponent;

        boolean renderVisible = formComponent.isRenderAllowed() && formComponent.isVisibilityAllowed() && formComponent.isVisible();

        if (formComponent.isRequired() && renderVisible)

        { RequestCycle.get().getResponse().write("<span class=\"required\">*</span>"); }

        else if (!renderVisible)

        { markupStream.skipComponent(); return true; }

        }
        }

        container.autoAdd(wc, markupStream);
        return true;
        }
        return false;
        }

        Show
        robert mcguinness added a comment - I made some modifications for our use case, maybe others would be interested. Renders a required "*" for the labels. public boolean resolve(MarkupContainer container, MarkupStream markupStream, ComponentTag tag) { // make sure any raw markup with wicket:for attrs is a component if (WICKET_FOR_CONTAINER_ID.equals(tag.getId())) { Component wc; if (tag.isOpenClose()) { wc = new WebComponent(WICKET_FOR_CONTAINER_ID + container.getPage().getAutoIndex()); } else { wc = new TransparentContainer(WICKET_FOR_CONTAINER_ID + container.getPage().getAutoIndex()); } String refId = tag.getAttributes().getString(WICKET_FOR_ATTRIBUTE_NAME); if (!Strings.isEmpty(refId)) { refId = refId.trim(); // Find the referred sibling component by id. Component refComponent = container.getParent().get(refId); if (refComponent instanceof FormComponent<?>) { FormComponent<?> formComponent = (FormComponent<?>) refComponent; boolean renderVisible = formComponent.isRenderAllowed() && formComponent.isVisibilityAllowed() && formComponent.isVisible(); if (formComponent.isRequired() && renderVisible) { RequestCycle.get().getResponse().write("<span class=\"required\">*</span>"); } else if (!renderVisible) { markupStream.skipComponent(); return true; } } } container.autoAdd(wc, markupStream); return true; } return false; }
        Erik van Oosten made changes -
        Attachment WICKET-1469-for-wicket-1.4.x.patch [ 12428823 ]
        Hide
        Erik van Oosten added a comment -

        Attachment WICKET-1469-for-wicket-1.4.x.patch can be applied to branch 1.4.x.

        Supported:

        • "wicket:for" attribute, value refers to any component
        • during rendering the "for" attribute is generated with as value the referred component's markup id
        • referred component's will automatically render its markup id when it is located /after/ the wicket:for attribute in the markup stream

        Not supported:

        • referred component will /not/ automatically render its markup id when it is located before the wicket:for attribute in the markup stream

        Any clues on how to support the latter are much appreciated. The alternative is to remove auto rendering of markup ids completely.

        Show
        Erik van Oosten added a comment - Attachment WICKET-1469 -for-wicket-1.4.x.patch can be applied to branch 1.4.x. Supported: "wicket:for" attribute, value refers to any component during rendering the "for" attribute is generated with as value the referred component's markup id referred component's will automatically render its markup id when it is located /after/ the wicket:for attribute in the markup stream Not supported: referred component will /not/ automatically render its markup id when it is located before the wicket:for attribute in the markup stream Any clues on how to support the latter are much appreciated. The alternative is to remove auto rendering of markup ids completely.
        Show
        Erik van Oosten added a comment - See e-mail discussion: http://old.nabble.com/Request-for-input-on-new-feature-idea%3A-wicket%3Afor-attribute-td26765933.html
        Hide
        Vladimir Kovalyuk added a comment -

        I would like more unified form similar to wicket:message.

        wicket:refid="for:username"

        Show
        Vladimir Kovalyuk added a comment - I would like more unified form similar to wicket:message. wicket:refid="for:username"
        Johan Compagner made changes -
        Fix Version/s 1.5-M1 [ 12313078 ]
        Igor Vaynberg made changes -
        Assignee Gerolf Seitz [ seitz ]
        Igor Vaynberg made changes -
        Assignee Igor Vaynberg [ ivaynberg ] Gerolf Seitz [ seitz ]
        Johan Compagner made changes -
        Field Original Value New Value
        Assignee Igor Vaynberg [ ivaynberg ]
        Jan Kriesten created issue -

          People

          • Assignee:
            Igor Vaynberg
            Reporter:
            Jan Kriesten
          • Votes:
            2 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development