I just run into a use-case of addOrRemove() just now while refactoring some
code to support Accessibility and I through you might want to see some code
snippets:

ConfirmMessagePanel.html
...
<form wicket:id="form">
            <table width="100%" height="200px">
                <tr>
                    <td class="infobox" align="center" colspan="2">
                        <span wicket:id="icon"><img
src="../../../../../../../../../../../../../src/web/images/help.gif"/></span
>&nbsp;&nbsp;<span class="infobox" wicket:id="message">[[message]]</span>
                    </td>
                </tr>
...

ConfirmMessagePanel.java
...
public ConfirmMessagePanel(String id, IModel<String> confirmMessageModel,
IModel<String> confirmBtnModel, IModel<String> cancelBtnModel) {
        super(id);
        form = new Form<Void>("form");
        form.add(new IconPanel("icon", TYPE.Help));
...

InfoMessagePanel extends ConfirmMessagePanel and this is how it looks like:

InfoMessagePanel.html (not too many changes here in this simple example, but
this can have other components added especially if you use <wicket:extend
/>)
...
<form wicket:id="form">
            <table width="100%" height="200px">
                <tr>
                    <td class="infobox" align="center">
                        <span wicket:id="icon"><img
src="../../../../../../../../../../../../../src/web/images/info.gif"/></span
>&nbsp;&nbsp;<span class="infobox" wicket:id="message">[[Info
Message]]</span>
                    </td>
                </tr>
...

InfoMessagePanel.java
...
public InfoMessagePanel(String id, IModel<String> message, IModel<String>
cancelBtnModel) {
        super(id, message, cancelBtnModel, cancelBtnModel);
        getForm().addOrReplace(new IconPanel("icon", TYPE.Info));
        setConfirmationButtonVisible(false); // my own method not a Wiki one
    }
...

Rambabu, I hope this feed your appetite :)

~ Thank you,
  Paul Bors

-----Original Message-----
From: Paul Bors [mailto:[email protected]] 
Sent: Friday, August 31, 2012 12:03 PM
To: [email protected]
Subject: RE: override wicket mark up

Have you checked the wiki page on the View Layer?
https://cwiki.apache.org/WICKET/view-layer.html

In your original e-mail you showed the following Wicket component tree:

[Panel let's call it TogglePanel.java]
  - propertyValue (let's call it ReadOnlyPanel.java)
    - label
    - label

And I believe you wanted to "override" it with the following Wicket
component tree:

[Panel]
  - propertyValue (let's call it EditGroupPanel.java)
    - adminGroupTabs
      - adminGroupTabLink
        - label
    - adminGroupView
      - value

Obviously this is *not* an override, but a full replacement.
A true override would preserve the same Wicket component tree but replace
the HTML (ie: presentation layer) and your Java class would extend from the
class that's overriding and call super with not too much other work to do.

You got lucky because your panel in this case has a root component id of
"propertyValue".

Thus all you would have to do is use the addOrReplace() inside the
TogglePanel.java and toggle the panel that will be added:
if(isReadOnly) {
  addOrReplace(new ReadOnlyPanel("propertyValue")); } else {
  addOrReplace(new EditGroupPanel("propertyValue")); }

For the JavaDoc on addOrReplace see:
http://wicket.apache.org/apidocs/1.5/org/apache/wicket/MarkupContainer.html#
addOrReplace(org.apache.wicket.Component...)

~ Thank you,
  Paul Bors

-----Original Message-----
From: ramlael [mailto:[email protected]]
Sent: Thursday, August 30, 2012 5:10 AM
To: [email protected]
Subject: Re: override wicket mark up

Hi Martin,

Once I call super(model) in extended class, its expecting markup
(wicket:ids) should be in same order.

Please can you provide sample code, how the replace or replaceWith will
work.

Regards,
Rambabu



--
View this message in context:
http://apache-wicket.1842946.n4.nabble.com/override-wicket-mark-up-tp4651624
p4651640.html
Sent from the Users forum mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]




---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to