Hi All,

 

I have been struggling with the following problem for quite a while.  I
have a custom component for which I have defined a parameter with a
binding type of property.  I have the component within a form that is
within a loop on my page.  The parameter of my component is bound to the
value of the "value" parameter of the loop.  The value of my parameter
ends up always being null, when the value is requested in my component,
a PropBinding calls the getter on my page class.  Everything is good so
far as rendering goes. The problem is that when I submit the form, I
want to access my value, so the PropBinding again calls the getter on my
page class.  At this point, I get a NullPointerException since the value
of the property in my page class is now null since the loop is no longer
being rendered.  So my question is this:  Is there a way to retaint the
value of the property in the component instead of it always being null
and having the PropBinding call the getter on the page?  (BTW, I am
using version 5.0.13)

 

Here's a snippet of the component java class:

 

public class MenuEntry {

     // This setter never gets called.

    public void setModel(Model model) {

        this.model = model;

    }

 

     // This works fine because it is only called when rendering.

    public String getModelName() {

        return model.getName();

    }

 

     // NullPointerException gets thrown because the PropBinding calls
the getter

     // on the page class and the property is null since the loop is no
longer being renderes.

    public void setModelName(String name) {

        model.setName(name);

    }

 

    // a bunch of non-relevant methods not shown...

 

    @Parameter(required = true, principal = true)

    private Model model;

 

    // bunch of non-relevant fields not shown...

}

 

And a snippet of the page class:

 

public class Build {

    // bunch of non-relevant methods not shown...

 

    public Model getMenuModel() {

        return menuModel;

    }

 

    public void setMenuModel(Model model) {

        menuModel = model;

    }

 

    // bunch of non-relevant fields not shown...

 

    private Model menuModel;

}

 

And finally, a snippet of the page tml:

 

<!-- bunch of non-relevant html not shown -->

<t:loop t:source="menuModels" t:value="menuModel">


    <t:form t:id="menuEntryDetails" context="menuModel">

        <t:menuentry t:id="menuEntryComponent" model="menuModel"/>


        <div><input type="submit" value="Save"/></div>

    </t:form>

</t:loop>

<!-- bunch more non-relevant html not shown -->

 

 

Thanks very much in advance for any help!

 

Brendan McNichols

Reply via email to