You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Eyal Golan <eg...@gmail.com> on 2008/09/15 14:37:47 UTC

Markup Inheritance - Is this correct?

Hello,
I have an abstract page that has a form.
The html looks like this:
<?xml version="1.0"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "
http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
    xmlns:wicket="http://wicket.sourceforge.net/" xml:lang="en" lang="en">

<body>

<form wicket:id="form">
<div wicket:id="params"></div>
<table cellspacing="1" width="100%" border="0">
    <tr>
        <td style="text-align: center;">
        <button type="submit" wicket:id="ok">[Text OK]</button>
        <button type="submit" wicket:id="cancel">[Text Cancel]</button>
        </td>
    </tr>
</table>
</form>
<div wicket:id="feedback" class="errorFeedbackPanel">[feedback
here]</div>
</body>

</html>

In the java file I don't add the "params" component.
Instead, there's a variable 'form', which is protected.
Each sub page adds the panel it needs to the form.
Example:
form.add(new UniverseConfigurationSelectPanel("params", this, false));

I tried to use the markup inheritance with <wicket:extends> and
<wicket:child/>
But when I put the <wicket:extends> in the location if <div
wicket:id="params"></div>, I get the regular exception if mismatch in the
hierarchy.
Did I hack or is it legal to do what I did?

I need the params inside the form in order to check validations , errors and
to use the feedback panel.

Thanks

-- 
Eyal Golan
egolan74@gmail.com

Visit: http://jvdrums.sourceforge.net/
LinkedIn: http://www.linkedin.com/in/egolan74

P Save a tree. Please don't print this e-mail unless it's really necessary

Re: Markup Inheritance - Is this correct?

Posted by Eyal Golan <eg...@gmail.com>.
thanks,
I'll try it soon :)

On Mon, Sep 15, 2008 at 4:35 PM, Ernesto Reinaldo Barreiro <
reiern70@gmail.com> wrote:

> Yes, I know what you mean... In that case what I would do, but don know if
> it is the best practice..., is just move the call to
>
> Component params = createParams("params");
> form.add(params);
>
> to the onBeforeRender() method... Maybe you want to keep a reference to the
> params components so that you create it only once...
>
> if(params== null) {
>    params = createParams("params");
>   form.add(params);
> }
> I do such things frequently but don't know if there are better ways to
> achieve the same in a more elegant way...
>
> Best,
>
> Ernesto
>
>
> On Mon, Sep 15, 2008 at 3:19 PM, Eyal Golan <eg...@gmail.com> wrote:
>
> > Thanks Ernesto,
> >
> > This is exactly what I initially did.
> > But then I had another problem.
> > In one of the sub pages, the panel needed to use a variable of it (the
> sub
> > page).
> > The problem is that this variable is not initialized when I call the
> > createParams("params"); in the super.
> >
> > MyInheritClass extends MyBaseClass {
> > MyImportantMember member;
> > MyInheritClass (...) {
> > member = new MyImportantMember(...);
> > ...
> > }
> >
> > @Override
> > Component createParams(String id) {
> > Panel p = new MyGreatPanel(member, ...);
> > ...
> > }
> >
> > Actually the member is used for an IModel:
> > The not initialized variable is parametersBean.
> > MyGreatPanel {
> > ...
> >    private IModel getValuesOfFieldModel() {
> >        IModel valuesOfFieldsModel = new AbstractReadOnlyModel() {
> >            private static final long serialVersionUID = 1L;
> >
> >            @Override
> >            public Object getObject() {
> >                if (parametersBean.getByField() == null) { // Here I get
> the
> > NullPointerException
> >                    return Collections.emptyList();
> >                }
> >                Configuration configuration =
> > sageDal.getConfiguration(getConfigurationName());
> >                Set<ConfigurationUser> entities =
> > sageDal.getConfigurationUsers(configuration);
> >                List<String> result =
> >                        sageDal.getFieldValues(configuration, entities,
> > parametersBean
> >                                .getByField());
> >                return result;
> >            }
> >
> >        };
> >        return valuesOfFieldsModel;
> >    }
> >
> > }
> >
> > What do you think?
> >
> > Thanks,
> > Eyal
> >
> > On Mon, Sep 15, 2008 at 3:53 PM, Ernesto Reinaldo Barreiro <
> > reiern70@gmail.com> wrote:
> >
> > > Hi Eyal,
> > >
> > > If your class is abstract why don't you add a method
> > >
> > > protected abstract Component createParams(String id);
> > >
> > > and on the constructor
> > >
> > > MyBasePage(...)
> > > {
> > > Form form = new Form("form");
> > > add(form);
> > > Component params = createParams("params");
> > > form.add(params);
> > > }
> > >
> > > That way it is clear the you have to provide a params component and you
> > > also do not forget to add it to form (as the super class will take care
> > of
> > > that part;-).
> > >
> > > Best
> > >
> > > Ernesto
> > >
> > >
> > > Eyal Golan wrote:
> > >
> > >> Hello,
> > >> I have an abstract page that has a form.
> > >> The html looks like this:
> > >> <?xml version="1.0"?>
> > >> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "
> > >> http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
> > >> <html xmlns="http://www.w3.org/1999/xhtml"
> > >>    xmlns:wicket="http://wicket.sourceforge.net/" xml:lang="en"
> > lang="en">
> > >>
> > >> <body>
> > >>
> > >> <form wicket:id="form">
> > >> <div wicket:id="params"></div>
> > >> <table cellspacing="1" width="100%" border="0">
> > >>    <tr>
> > >>        <td style="text-align: center;">
> > >>        <button type="submit" wicket:id="ok">[Text OK]</button>
> > >>        <button type="submit" wicket:id="cancel">[Text Cancel]</button>
> > >>        </td>
> > >>    </tr>
> > >> </table>
> > >> </form>
> > >> <div wicket:id="feedback" class="errorFeedbackPanel">[feedback
> > >> here]</div>
> > >> </body>
> > >>
> > >> </html>
> > >>
> > >> In the java file I don't add the "params" component.
> > >> Instead, there's a variable 'form', which is protected.
> > >> Each sub page adds the panel it needs to the form.
> > >> Example:
> > >> form.add(new UniverseConfigurationSelectPanel("params", this, false));
> > >>
> > >> I tried to use the markup inheritance with <wicket:extends> and
> > >> <wicket:child/>
> > >> But when I put the <wicket:extends> in the location if <div
> > >> wicket:id="params"></div>, I get the regular exception if mismatch in
> > the
> > >> hierarchy.
> > >> Did I hack or is it legal to do what I did?
> > >>
> > >> I need the params inside the form in order to check validations ,
> errors
> > >> and
> > >> to use the feedback panel.
> > >>
> > >> Thanks
> > >>
> > >>
> > >>
> > >
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> > > For additional commands, e-mail: users-help@wicket.apache.org
> > >
> > >
> >
> >
> > --
> > Eyal Golan
> > egolan74@gmail.com
> >
> > Visit: http://jvdrums.sourceforge.net/
> > LinkedIn: http://www.linkedin.com/in/egolan74
> >
> > P Save a tree. Please don't print this e-mail unless it's really
> necessary
> >
>



-- 
Eyal Golan
egolan74@gmail.com

Visit: http://jvdrums.sourceforge.net/
LinkedIn: http://www.linkedin.com/in/egolan74

P Save a tree. Please don't print this e-mail unless it's really necessary

Re: Markup Inheritance - Is this correct?

Posted by Eyal Golan <eg...@gmail.com>.
Wonderful :)
Works like a charm

On Mon, Sep 15, 2008 at 4:57 PM, Ernesto Reinaldo Barreiro <
reiern70@gmail.com> wrote:

> Eyal,
>
> If you look into the code of the Palette component you will see:
>
> @Override
>    protected void onBeforeRender()
>    {
>        if (!hasBeenRendered())
>        {
>            initFactories();
>        }
>        super.onBeforeRender();
>    }
>
>
>    /**
>     * One-time init method for components that are created via overridable
> factories. This method
>     * is here because we do not want to call overridable methods form
> palette's constructor.
>     */
>    private void initFactories()
>    {
>        recorderComponent = newRecorderComponent();
>        add(recorderComponent);
>
>        choicesComponent = newChoicesComponent();
>        add(choicesComponent);
>
>        selectionComponent = newSelectionComponent();
>        add(selectionComponent);
>
>
>        add(newAddComponent());
>        add(newRemoveComponent());
>        add(newUpComponent().setVisible(allowOrder));
>        add(newDownComponent().setVisible(allowOrder));
>
>        add(newAvailableHeader(AVAILABLE_HEADER_ID));
>        add(newSelectedHeader(SELECTED_HEADER_ID));
>    }
>
> So, it seems that's a good way to deal with your problem...
>
> Best,
>
> Ernesto
>
> On Mon, Sep 15, 2008 at 3:35 PM, Ernesto Reinaldo Barreiro <
> reiern70@gmail.com> wrote:
>
> > Yes, I know what you mean... In that case what I would do, but don know
> if
> > it is the best practice..., is just move the call to
> >
> > Component params = createParams("params");
> > form.add(params);
> >
> > to the onBeforeRender() method... Maybe you want to keep a reference to
> the
> > params components so that you create it only once...
> >
> > if(params== null) {
> >    params = createParams("params");
> >    form.add(params);
> > }
> > I do such things frequently but don't know if there are better ways to
> > achieve the same in a more elegant way...
> >
> > Best,
> >
> > Ernesto
> >
> >
> >
> > On Mon, Sep 15, 2008 at 3:19 PM, Eyal Golan <eg...@gmail.com> wrote:
> >
> >> Thanks Ernesto,
> >>
> >> This is exactly what I initially did.
> >> But then I had another problem.
> >> In one of the sub pages, the panel needed to use a variable of it (the
> sub
> >> page).
> >> The problem is that this variable is not initialized when I call the
> >> createParams("params"); in the super.
> >>
> >> MyInheritClass extends MyBaseClass {
> >> MyImportantMember member;
> >> MyInheritClass (...) {
> >> member = new MyImportantMember(...);
> >> ...
> >> }
> >>
> >> @Override
> >> Component createParams(String id) {
> >> Panel p = new MyGreatPanel(member, ...);
> >> ...
> >> }
> >>
> >> Actually the member is used for an IModel:
> >> The not initialized variable is parametersBean.
> >> MyGreatPanel {
> >> ...
> >>    private IModel getValuesOfFieldModel() {
> >>        IModel valuesOfFieldsModel = new AbstractReadOnlyModel() {
> >>            private static final long serialVersionUID = 1L;
> >>
> >>            @Override
> >>            public Object getObject() {
> >>                if (parametersBean.getByField() == null) { // Here I get
> >> the
> >> NullPointerException
> >>                    return Collections.emptyList();
> >>                }
> >>                Configuration configuration =
> >> sageDal.getConfiguration(getConfigurationName());
> >>                Set<ConfigurationUser> entities =
> >> sageDal.getConfigurationUsers(configuration);
> >>                List<String> result =
> >>                        sageDal.getFieldValues(configuration, entities,
> >> parametersBean
> >>                                .getByField());
> >>                return result;
> >>            }
> >>
> >>        };
> >>        return valuesOfFieldsModel;
> >>    }
> >>
> >> }
> >>
> >> What do you think?
> >>
> >> Thanks,
> >> Eyal
> >>
> >> On Mon, Sep 15, 2008 at 3:53 PM, Ernesto Reinaldo Barreiro <
> >> reiern70@gmail.com> wrote:
> >>
> >> > Hi Eyal,
> >> >
> >> > If your class is abstract why don't you add a method
> >> >
> >> > protected abstract Component createParams(String id);
> >> >
> >> > and on the constructor
> >> >
> >> > MyBasePage(...)
> >> > {
> >> > Form form = new Form("form");
> >> > add(form);
> >> > Component params = createParams("params");
> >> > form.add(params);
> >> > }
> >> >
> >> > That way it is clear the you have to provide a params component and
> you
> >> > also do not forget to add it to form (as the super class will take
> care
> >> of
> >> > that part;-).
> >> >
> >> > Best
> >> >
> >> > Ernesto
> >> >
> >> >
> >> > Eyal Golan wrote:
> >> >
> >> >> Hello,
> >> >> I have an abstract page that has a form.
> >> >> The html looks like this:
> >> >> <?xml version="1.0"?>
> >> >> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "
> >> >> http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
> >> >> <html xmlns="http://www.w3.org/1999/xhtml"
> >> >>    xmlns:wicket="http://wicket.sourceforge.net/" xml:lang="en"
> >> lang="en">
> >> >>
> >> >> <body>
> >> >>
> >> >> <form wicket:id="form">
> >> >> <div wicket:id="params"></div>
> >> >> <table cellspacing="1" width="100%" border="0">
> >> >>    <tr>
> >> >>        <td style="text-align: center;">
> >> >>        <button type="submit" wicket:id="ok">[Text OK]</button>
> >> >>        <button type="submit" wicket:id="cancel">[Text
> Cancel]</button>
> >> >>        </td>
> >> >>    </tr>
> >> >> </table>
> >> >> </form>
> >> >> <div wicket:id="feedback" class="errorFeedbackPanel">[feedback
> >> >> here]</div>
> >> >> </body>
> >> >>
> >> >> </html>
> >> >>
> >> >> In the java file I don't add the "params" component.
> >> >> Instead, there's a variable 'form', which is protected.
> >> >> Each sub page adds the panel it needs to the form.
> >> >> Example:
> >> >> form.add(new UniverseConfigurationSelectPanel("params", this,
> false));
> >> >>
> >> >> I tried to use the markup inheritance with <wicket:extends> and
> >> >> <wicket:child/>
> >> >> But when I put the <wicket:extends> in the location if <div
> >> >> wicket:id="params"></div>, I get the regular exception if mismatch in
> >> the
> >> >> hierarchy.
> >> >> Did I hack or is it legal to do what I did?
> >> >>
> >> >> I need the params inside the form in order to check validations ,
> >> errors
> >> >> and
> >> >> to use the feedback panel.
> >> >>
> >> >> Thanks
> >> >>
> >> >>
> >> >>
> >> >
> >> >
> >> > ---------------------------------------------------------------------
> >> > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> >> > For additional commands, e-mail: users-help@wicket.apache.org
> >> >
> >> >
> >>
> >>
> >> --
> >> Eyal Golan
> >> egolan74@gmail.com
> >>
> >> Visit: http://jvdrums.sourceforge.net/
> >> LinkedIn: http://www.linkedin.com/in/egolan74
> >>
> >> P Save a tree. Please don't print this e-mail unless it's really
> necessary
> >>
> >
> >
>



-- 
Eyal Golan
egolan74@gmail.com

Visit: http://jvdrums.sourceforge.net/
LinkedIn: http://www.linkedin.com/in/egolan74

P Save a tree. Please don't print this e-mail unless it's really necessary

Re: Markup Inheritance - Is this correct?

Posted by Ernesto Reinaldo Barreiro <re...@gmail.com>.
Eyal,

If you look into the code of the Palette component you will see:

@Override
    protected void onBeforeRender()
    {
        if (!hasBeenRendered())
        {
            initFactories();
        }
        super.onBeforeRender();
    }


    /**
     * One-time init method for components that are created via overridable
factories. This method
     * is here because we do not want to call overridable methods form
palette's constructor.
     */
    private void initFactories()
    {
        recorderComponent = newRecorderComponent();
        add(recorderComponent);

        choicesComponent = newChoicesComponent();
        add(choicesComponent);

        selectionComponent = newSelectionComponent();
        add(selectionComponent);


        add(newAddComponent());
        add(newRemoveComponent());
        add(newUpComponent().setVisible(allowOrder));
        add(newDownComponent().setVisible(allowOrder));

        add(newAvailableHeader(AVAILABLE_HEADER_ID));
        add(newSelectedHeader(SELECTED_HEADER_ID));
    }

So, it seems that's a good way to deal with your problem...

Best,

Ernesto

On Mon, Sep 15, 2008 at 3:35 PM, Ernesto Reinaldo Barreiro <
reiern70@gmail.com> wrote:

> Yes, I know what you mean... In that case what I would do, but don know if
> it is the best practice..., is just move the call to
>
> Component params = createParams("params");
> form.add(params);
>
> to the onBeforeRender() method... Maybe you want to keep a reference to the
> params components so that you create it only once...
>
> if(params== null) {
>    params = createParams("params");
>    form.add(params);
> }
> I do such things frequently but don't know if there are better ways to
> achieve the same in a more elegant way...
>
> Best,
>
> Ernesto
>
>
>
> On Mon, Sep 15, 2008 at 3:19 PM, Eyal Golan <eg...@gmail.com> wrote:
>
>> Thanks Ernesto,
>>
>> This is exactly what I initially did.
>> But then I had another problem.
>> In one of the sub pages, the panel needed to use a variable of it (the sub
>> page).
>> The problem is that this variable is not initialized when I call the
>> createParams("params"); in the super.
>>
>> MyInheritClass extends MyBaseClass {
>> MyImportantMember member;
>> MyInheritClass (...) {
>> member = new MyImportantMember(...);
>> ...
>> }
>>
>> @Override
>> Component createParams(String id) {
>> Panel p = new MyGreatPanel(member, ...);
>> ...
>> }
>>
>> Actually the member is used for an IModel:
>> The not initialized variable is parametersBean.
>> MyGreatPanel {
>> ...
>>    private IModel getValuesOfFieldModel() {
>>        IModel valuesOfFieldsModel = new AbstractReadOnlyModel() {
>>            private static final long serialVersionUID = 1L;
>>
>>            @Override
>>            public Object getObject() {
>>                if (parametersBean.getByField() == null) { // Here I get
>> the
>> NullPointerException
>>                    return Collections.emptyList();
>>                }
>>                Configuration configuration =
>> sageDal.getConfiguration(getConfigurationName());
>>                Set<ConfigurationUser> entities =
>> sageDal.getConfigurationUsers(configuration);
>>                List<String> result =
>>                        sageDal.getFieldValues(configuration, entities,
>> parametersBean
>>                                .getByField());
>>                return result;
>>            }
>>
>>        };
>>        return valuesOfFieldsModel;
>>    }
>>
>> }
>>
>> What do you think?
>>
>> Thanks,
>> Eyal
>>
>> On Mon, Sep 15, 2008 at 3:53 PM, Ernesto Reinaldo Barreiro <
>> reiern70@gmail.com> wrote:
>>
>> > Hi Eyal,
>> >
>> > If your class is abstract why don't you add a method
>> >
>> > protected abstract Component createParams(String id);
>> >
>> > and on the constructor
>> >
>> > MyBasePage(...)
>> > {
>> > Form form = new Form("form");
>> > add(form);
>> > Component params = createParams("params");
>> > form.add(params);
>> > }
>> >
>> > That way it is clear the you have to provide a params component and you
>> > also do not forget to add it to form (as the super class will take care
>> of
>> > that part;-).
>> >
>> > Best
>> >
>> > Ernesto
>> >
>> >
>> > Eyal Golan wrote:
>> >
>> >> Hello,
>> >> I have an abstract page that has a form.
>> >> The html looks like this:
>> >> <?xml version="1.0"?>
>> >> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "
>> >> http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
>> >> <html xmlns="http://www.w3.org/1999/xhtml"
>> >>    xmlns:wicket="http://wicket.sourceforge.net/" xml:lang="en"
>> lang="en">
>> >>
>> >> <body>
>> >>
>> >> <form wicket:id="form">
>> >> <div wicket:id="params"></div>
>> >> <table cellspacing="1" width="100%" border="0">
>> >>    <tr>
>> >>        <td style="text-align: center;">
>> >>        <button type="submit" wicket:id="ok">[Text OK]</button>
>> >>        <button type="submit" wicket:id="cancel">[Text Cancel]</button>
>> >>        </td>
>> >>    </tr>
>> >> </table>
>> >> </form>
>> >> <div wicket:id="feedback" class="errorFeedbackPanel">[feedback
>> >> here]</div>
>> >> </body>
>> >>
>> >> </html>
>> >>
>> >> In the java file I don't add the "params" component.
>> >> Instead, there's a variable 'form', which is protected.
>> >> Each sub page adds the panel it needs to the form.
>> >> Example:
>> >> form.add(new UniverseConfigurationSelectPanel("params", this, false));
>> >>
>> >> I tried to use the markup inheritance with <wicket:extends> and
>> >> <wicket:child/>
>> >> But when I put the <wicket:extends> in the location if <div
>> >> wicket:id="params"></div>, I get the regular exception if mismatch in
>> the
>> >> hierarchy.
>> >> Did I hack or is it legal to do what I did?
>> >>
>> >> I need the params inside the form in order to check validations ,
>> errors
>> >> and
>> >> to use the feedback panel.
>> >>
>> >> Thanks
>> >>
>> >>
>> >>
>> >
>> >
>> > ---------------------------------------------------------------------
>> > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> > For additional commands, e-mail: users-help@wicket.apache.org
>> >
>> >
>>
>>
>> --
>> Eyal Golan
>> egolan74@gmail.com
>>
>> Visit: http://jvdrums.sourceforge.net/
>> LinkedIn: http://www.linkedin.com/in/egolan74
>>
>> P Save a tree. Please don't print this e-mail unless it's really necessary
>>
>
>

Re: Markup Inheritance - Is this correct?

Posted by Ernesto Reinaldo Barreiro <re...@gmail.com>.
Yes, I know what you mean... In that case what I would do, but don know if
it is the best practice..., is just move the call to

Component params = createParams("params");
form.add(params);

to the onBeforeRender() method... Maybe you want to keep a reference to the
params components so that you create it only once...

if(params== null) {
   params = createParams("params");
   form.add(params);
}
I do such things frequently but don't know if there are better ways to
achieve the same in a more elegant way...

Best,

Ernesto


On Mon, Sep 15, 2008 at 3:19 PM, Eyal Golan <eg...@gmail.com> wrote:

> Thanks Ernesto,
>
> This is exactly what I initially did.
> But then I had another problem.
> In one of the sub pages, the panel needed to use a variable of it (the sub
> page).
> The problem is that this variable is not initialized when I call the
> createParams("params"); in the super.
>
> MyInheritClass extends MyBaseClass {
> MyImportantMember member;
> MyInheritClass (...) {
> member = new MyImportantMember(...);
> ...
> }
>
> @Override
> Component createParams(String id) {
> Panel p = new MyGreatPanel(member, ...);
> ...
> }
>
> Actually the member is used for an IModel:
> The not initialized variable is parametersBean.
> MyGreatPanel {
> ...
>    private IModel getValuesOfFieldModel() {
>        IModel valuesOfFieldsModel = new AbstractReadOnlyModel() {
>            private static final long serialVersionUID = 1L;
>
>            @Override
>            public Object getObject() {
>                if (parametersBean.getByField() == null) { // Here I get the
> NullPointerException
>                    return Collections.emptyList();
>                }
>                Configuration configuration =
> sageDal.getConfiguration(getConfigurationName());
>                Set<ConfigurationUser> entities =
> sageDal.getConfigurationUsers(configuration);
>                List<String> result =
>                        sageDal.getFieldValues(configuration, entities,
> parametersBean
>                                .getByField());
>                return result;
>            }
>
>        };
>        return valuesOfFieldsModel;
>    }
>
> }
>
> What do you think?
>
> Thanks,
> Eyal
>
> On Mon, Sep 15, 2008 at 3:53 PM, Ernesto Reinaldo Barreiro <
> reiern70@gmail.com> wrote:
>
> > Hi Eyal,
> >
> > If your class is abstract why don't you add a method
> >
> > protected abstract Component createParams(String id);
> >
> > and on the constructor
> >
> > MyBasePage(...)
> > {
> > Form form = new Form("form");
> > add(form);
> > Component params = createParams("params");
> > form.add(params);
> > }
> >
> > That way it is clear the you have to provide a params component and you
> > also do not forget to add it to form (as the super class will take care
> of
> > that part;-).
> >
> > Best
> >
> > Ernesto
> >
> >
> > Eyal Golan wrote:
> >
> >> Hello,
> >> I have an abstract page that has a form.
> >> The html looks like this:
> >> <?xml version="1.0"?>
> >> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "
> >> http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
> >> <html xmlns="http://www.w3.org/1999/xhtml"
> >>    xmlns:wicket="http://wicket.sourceforge.net/" xml:lang="en"
> lang="en">
> >>
> >> <body>
> >>
> >> <form wicket:id="form">
> >> <div wicket:id="params"></div>
> >> <table cellspacing="1" width="100%" border="0">
> >>    <tr>
> >>        <td style="text-align: center;">
> >>        <button type="submit" wicket:id="ok">[Text OK]</button>
> >>        <button type="submit" wicket:id="cancel">[Text Cancel]</button>
> >>        </td>
> >>    </tr>
> >> </table>
> >> </form>
> >> <div wicket:id="feedback" class="errorFeedbackPanel">[feedback
> >> here]</div>
> >> </body>
> >>
> >> </html>
> >>
> >> In the java file I don't add the "params" component.
> >> Instead, there's a variable 'form', which is protected.
> >> Each sub page adds the panel it needs to the form.
> >> Example:
> >> form.add(new UniverseConfigurationSelectPanel("params", this, false));
> >>
> >> I tried to use the markup inheritance with <wicket:extends> and
> >> <wicket:child/>
> >> But when I put the <wicket:extends> in the location if <div
> >> wicket:id="params"></div>, I get the regular exception if mismatch in
> the
> >> hierarchy.
> >> Did I hack or is it legal to do what I did?
> >>
> >> I need the params inside the form in order to check validations , errors
> >> and
> >> to use the feedback panel.
> >>
> >> Thanks
> >>
> >>
> >>
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> > For additional commands, e-mail: users-help@wicket.apache.org
> >
> >
>
>
> --
> Eyal Golan
> egolan74@gmail.com
>
> Visit: http://jvdrums.sourceforge.net/
> LinkedIn: http://www.linkedin.com/in/egolan74
>
> P Save a tree. Please don't print this e-mail unless it's really necessary
>

Re: Markup Inheritance - Is this correct?

Posted by Eyal Golan <eg...@gmail.com>.
Thanks Ernesto,

This is exactly what I initially did.
But then I had another problem.
In one of the sub pages, the panel needed to use a variable of it (the sub
page).
The problem is that this variable is not initialized when I call the
createParams("params"); in the super.

MyInheritClass extends MyBaseClass {
MyImportantMember member;
MyInheritClass (...) {
member = new MyImportantMember(...);
...
}

@Override
Component createParams(String id) {
Panel p = new MyGreatPanel(member, ...);
...
}

Actually the member is used for an IModel:
The not initialized variable is parametersBean.
MyGreatPanel {
...
    private IModel getValuesOfFieldModel() {
        IModel valuesOfFieldsModel = new AbstractReadOnlyModel() {
            private static final long serialVersionUID = 1L;

            @Override
            public Object getObject() {
                if (parametersBean.getByField() == null) { // Here I get the
NullPointerException
                    return Collections.emptyList();
                }
                Configuration configuration =
sageDal.getConfiguration(getConfigurationName());
                Set<ConfigurationUser> entities =
sageDal.getConfigurationUsers(configuration);
                List<String> result =
                        sageDal.getFieldValues(configuration, entities,
parametersBean
                                .getByField());
                return result;
            }

        };
        return valuesOfFieldsModel;
    }

}

What do you think?

Thanks,
Eyal

On Mon, Sep 15, 2008 at 3:53 PM, Ernesto Reinaldo Barreiro <
reiern70@gmail.com> wrote:

> Hi Eyal,
>
> If your class is abstract why don't you add a method
>
> protected abstract Component createParams(String id);
>
> and on the constructor
>
> MyBasePage(...)
> {
> Form form = new Form("form");
> add(form);
> Component params = createParams("params");
> form.add(params);
> }
>
> That way it is clear the you have to provide a params component and you
> also do not forget to add it to form (as the super class will take care of
> that part;-).
>
> Best
>
> Ernesto
>
>
> Eyal Golan wrote:
>
>> Hello,
>> I have an abstract page that has a form.
>> The html looks like this:
>> <?xml version="1.0"?>
>> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "
>> http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
>> <html xmlns="http://www.w3.org/1999/xhtml"
>>    xmlns:wicket="http://wicket.sourceforge.net/" xml:lang="en" lang="en">
>>
>> <body>
>>
>> <form wicket:id="form">
>> <div wicket:id="params"></div>
>> <table cellspacing="1" width="100%" border="0">
>>    <tr>
>>        <td style="text-align: center;">
>>        <button type="submit" wicket:id="ok">[Text OK]</button>
>>        <button type="submit" wicket:id="cancel">[Text Cancel]</button>
>>        </td>
>>    </tr>
>> </table>
>> </form>
>> <div wicket:id="feedback" class="errorFeedbackPanel">[feedback
>> here]</div>
>> </body>
>>
>> </html>
>>
>> In the java file I don't add the "params" component.
>> Instead, there's a variable 'form', which is protected.
>> Each sub page adds the panel it needs to the form.
>> Example:
>> form.add(new UniverseConfigurationSelectPanel("params", this, false));
>>
>> I tried to use the markup inheritance with <wicket:extends> and
>> <wicket:child/>
>> But when I put the <wicket:extends> in the location if <div
>> wicket:id="params"></div>, I get the regular exception if mismatch in the
>> hierarchy.
>> Did I hack or is it legal to do what I did?
>>
>> I need the params inside the form in order to check validations , errors
>> and
>> to use the feedback panel.
>>
>> Thanks
>>
>>
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>


-- 
Eyal Golan
egolan74@gmail.com

Visit: http://jvdrums.sourceforge.net/
LinkedIn: http://www.linkedin.com/in/egolan74

P Save a tree. Please don't print this e-mail unless it's really necessary

Re: Markup Inheritance - Is this correct?

Posted by Ernesto Reinaldo Barreiro <re...@gmail.com>.
Hi Eyal,

If your class is abstract why don't you add a method

protected abstract Component createParams(String id);

and on the constructor

MyBasePage(...)
{
Form form = new Form("form");
add(form);
Component params = createParams("params");
form.add(params);
}

That way it is clear the you have to provide a params component and you 
also do not forget to add it to form (as the super class will take care 
of that part;-).

Best

Ernesto

Eyal Golan wrote:
> Hello,
> I have an abstract page that has a form.
> The html looks like this:
> <?xml version="1.0"?>
> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "
> http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
> <html xmlns="http://www.w3.org/1999/xhtml"
>     xmlns:wicket="http://wicket.sourceforge.net/" xml:lang="en" lang="en">
>
> <body>
>
> <form wicket:id="form">
> <div wicket:id="params"></div>
> <table cellspacing="1" width="100%" border="0">
>     <tr>
>         <td style="text-align: center;">
>         <button type="submit" wicket:id="ok">[Text OK]</button>
>         <button type="submit" wicket:id="cancel">[Text Cancel]</button>
>         </td>
>     </tr>
> </table>
> </form>
> <div wicket:id="feedback" class="errorFeedbackPanel">[feedback
> here]</div>
> </body>
>
> </html>
>
> In the java file I don't add the "params" component.
> Instead, there's a variable 'form', which is protected.
> Each sub page adds the panel it needs to the form.
> Example:
> form.add(new UniverseConfigurationSelectPanel("params", this, false));
>
> I tried to use the markup inheritance with <wicket:extends> and
> <wicket:child/>
> But when I put the <wicket:extends> in the location if <div
> wicket:id="params"></div>, I get the regular exception if mismatch in the
> hierarchy.
> Did I hack or is it legal to do what I did?
>
> I need the params inside the form in order to check validations , errors and
> to use the feedback panel.
>
> Thanks
>
>   


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org