Well you'll get into trouble with your component IDs. if you simply call
addToRepeater, your component has already an ID which might not be suitable.
We use a callback for such situations. e.g.
interface IComponent() {
Component getComponent(String id);
}
in the base page:
private RepeatingView view = new RepeatingView("foo");
protected void addToRepeater(IComponent comp) {
view.add(comp.getComponent(view.newChildId());
}
and in the sub page:
addToRepeater(new IComponent() {
public Component getComponent(String id) {
return new MyPanel(id);
}
});
you could also just request a childId from the super-class, but I think the
above way is more elegant :-)
regards,
Michael
Jeremy Thomerson-5 wrote:
>
> You can also do exactly as you mentioned....
>
> In your base page, have a repeating view (i.e. ListView) that simply loops
> over a "List<Component> childPanels"..... Then your method
> addToRepeater(Component component) will add to that list.
>
> Should work exactly as you described. What trickery is needed? I guess I
> miss that part.
>
> On Wed, Dec 10, 2008 at 5:20 PM, Nino Saturnino Martinez Vazquez Wael <
> [EMAIL PROTECTED]> wrote:
>
>> Scott,
>>
>> Think inheritance :)
>>
>> Just write a super which has abstract methods that returns components for
>> c1..c4() and thats it.. no need for trickery with
>> IMarkupResourceStreamProvider ...
>>
>> Should I elaborate more?
>>
>> You could also take a look at the wicketstuff accordion thing, it does
>> something along these lines[1]...
>>
>>
>> 1=
>> http://wicketstuff.org/confluence/display/STUFFWIKI/wicket-contrib-accordion
>>
>> regards
>>
>>
>> smackie604 wrote:
>>
>>> Hi,
>>>
>>> My team has adopted wicket as it's web framework and we have been busy
>>> creating a lot of interesting Panels to build pages for our product. It
>>> is
>>> turning out that most of the time all the components on the page are
>>> Panels
>>> and we end up with a situation like this:
>>>
>>> MyPage.java
>>> --------------
>>> public class MyPage extends BasePage
>>> {
>>> MyPage()
>>> {
>>> add(SomePanel("c1"));
>>> add(SomePanel("c2"));
>>> add(SomePanel("c3"));
>>> add(SomePanel("c4"));
>>> }
>>> }
>>>
>>> MyPage.html
>>> ---------------
>>> <wicket:extend>
>>> <wicket:container wicket:id="c1"/>
>>> <wicket:container wicket:id="c2"/>
>>> <wicket:container wicket:id="c3"/>
>>> <wicket:container wicket:id="c4"/>
>>> </wicket:extend>
>>>
>>> It would be nice if we didn't have to write html files for pages in
>>> these
>>> situations and instead just do something like this:
>>>
>>> MyPage.java
>>> --------------
>>> public class MyPage extends BasePage
>>> {
>>> MyPage()
>>> {
>>> addToRepeater(SomePanel("c1"));
>>> addToRepeater(SomePanel("c2"));
>>> addToRepeater(SomePanel("c3"));
>>> addToRepeater(SomePanel("c4"));
>>> }
>>> }
>>>
>>> Where BasePage will have a method called addToRepeater which just adds
>>> the
>>> component to the repeater.
>>> I see we could do some trickery by implementing
>>> IMarkupResourceStreamProvider on the BasePage to force the template of
>>> it's
>>> child classes to always use BasePage.html. I'm not sure this is the
>>> best
>>> way of doing this, does anyone have any comments on using this approach?
>>>
>>> Thanks,
>>>
>>> Scott
>>>
>>>
>>
>> --
>> -Wicket for love
>>
>> Nino Martinez Wael
>> Java Specialist @ Jayway DK
>> http://www.jayway.dk
>> +45 2936 7684
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [EMAIL PROTECTED]
>> For additional commands, e-mail: [EMAIL PROTECTED]
>>
>>
>
>
> --
> Jeremy Thomerson
> http://www.wickettraining.com
>
>
-----
Michael Sparer
http://talk-on-tech.blogspot.com
--
View this message in context:
http://www.nabble.com/Child-page-with-no-html-tp20945577p20952952.html
Sent from the Wicket - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]