Thank you Nino!

The solution could not have been any easier:)  Here is how I did this incase
anyone else starts thinking of complicated solutions like myself:

ParentPage.java
----------------
public abstract class ParentPage extends WebPage
{
        public static String COMPONENT_ID = "component";

        public ParentPage()
        {
                add( new ListView<Component>( "listview", getComponents() )
                {
                        protected void populateItem( ListItem<Component> item )
                        {
                                item.add( item.getModel().getObject() );
                        }
                } );
        }

        protected abstract List<Component> getComponents();
}

ParentPage.html
---------------
<html>
<head>
        <title></title>
</head>
<body>
        
                <div wicket:id="component">This is a component</div>
        
</body>
</html>

ChildPage.java
--------------
public class ChildPage extends ParentPage
{
        protected List<Component> getComponents()
        {
                List <Component> l = new ArrayList<Component>();
                l.add( new Label(COMPONENT_ID, "Component 1") );
                l.add( new Label(COMPONENT_ID, "Component 2") );
                l.add( new Label(COMPONENT_ID, "Component 3") );
                return l;
        }
}


Nino.Martinez 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]
> 
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Child-page-with-no-html-tp20945577p20947047.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]

Reply via email to