On Tue, October 07, 2008, Jeremy Thomerson wrote:

> Maybe supply some code as an example of what you're doing.  I really didn't
> understand your scenario below.

See the code below. I use a button panel which allows me to setup form
buttons in different ways within a page class hierarchy, i.e. an edit page 
inherits from a create page but has a button more. Now I want to be able
to add ajax buttons to the button panel.

public class MyButton extends Button {
    private final String buttonType;
    public static enum ButtonType {
        BUTTON("button"),
        SUBMIT("submit"),
        RESET("reset");
        private final String buttonType;
        private ButtonType(String buttonType) {
            this.buttonType = buttonType;
        }
        public String getButtonType() {
            return this.buttonType;
        }
    }
    public MyButton(String id, IModel model, ButtonType buttonType) {
        super(id, model);
        this.buttonType = buttonType.getButtonType();
    }
    public String getButtonType() {
        return this.buttonType;
    }
}

public class ButtonPanel extends Panel implements IMarkupResourceStreamProvider 
{
    private static final String CSS_CLASS = "buttonPanel";
    private final String cssClass;
    private List<ButtonWithType> buttons;
    public ButtonPanel(String id, List<ButtonWithType> buttons, String 
cssClass) {
        super(id);
        this.buttons = buttons;
        this.cssClass = cssClass;
        if (buttons != null && buttons.size() > 0) {
            for (ButtonWithType b : buttons) {
                add(b);
            }
        }
    }
    @Override
    public IResourceStream getMarkupResourceStream(MarkupContainer container, 
Class containerClass) {
        StringBuilder result = new StringBuilder();
        result.append("  <div class=\"" + this.cssClass + "\">\n");
        int i = 0;
        for (ButtonWithType b : this.buttons) {
            result.append("    <div class=\"" + this.cssClass +  (i == 0 ? " 
button leftButton" : " button") + "\">\n");
            result.append("      <input wicket:id=\"" + b.getId() + "\"\n");
            result.append("             type=\"" + b.getButtonType() + "\" 
class=\"" + this.cssClass + "\" />\n");
            result.append("    </div>\n");
            ++i;
        }
        result.append("  </div>\n");
        return new StringResourceStream("<wicket:panel>\n"
                + result.toString();
                + "</wicket:panel>\n");

    }
}


Martin

-- 
----------- / http://herbert.the-little-red-haired-girl.org / -------------
=+= 
Wer bist du, ungezaehltes Frauenzimmer? Du bist - bist du? - Die Leute sagen, 
du waerest - lass sie sagen, sie wissen nicht, wie der Kirchturm steht. 

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to