Peter,  thanks for you help. this is what eventually worked the
renderComponent method is what you seem to need to transfer values out of
contained components to the parameter

jwc:


<component-specification allow-body="no" class="
org.lls.web.registration.component.Phone">

 <component id="phone1" type="TextField">

<binding name="value" value="phone1"/>

</component>

<component id="phone2" type="TextField">

<binding name="value" value="phone2"/>

</component>

<component id="phone3" type="TextField">

<binding name="value" value="phone3"/>

</component>

Phone.java


public abstract class Phone extends BaseComponent implements IFormComponent,
ValidatableField{

public abstract String getPhone1();

public abstract void setPhone1(String phone1);

public abstract String getPhone2();

public abstract void setPhone2(String phone2);

public abstract String getPhone3();

public abstract void setPhone3(String phone3);

@Parameter(required = true)

public abstract String getAreaCode();

public abstract void setAreaCode(String areaCode);

@Parameter(required = true)

public abstract String getExchange();

public abstract void setExchange(String exchange);

@Parameter(required = true)

public abstract String getNumber();

public abstract void setNumber(String number);

protected void renderComponent(IMarkupWriter writer, IRequestCycle cycle) {

if (!cycle.isRewinding()) {

setPhone1(getAreaCode());

setPhone2(getExchange());

setPhone3(getNumber());

}

super.renderComponent(writer, cycle);

if (cycle.isRewinding()) {

setAreaCode(getPhone1());

setExchange(getPhone2());

setNumber(getPhone3());

}

}

public String getDisplayName() {

return "Day Phone";

}

}



On 3/11/06, Peter Svensson <[EMAIL PROTECTED]> wrote:
>
> Hmm. It's very odd.
> Could you try a smaller exampler just to see if there is something strange
> going on.
>
> For instance if you make a very small component that just shows a
> textfield;
>
> foo.html
>
> <div jwcid="foo" />
>
>
> foo.jwc
>
> <parameter name="bar" required="yes"/>
> <component id="mytextfield" type="TextField">
>   <binding name="value" value="bar"/>
> </component>
>
>
> And you have get/setBar() etc. in the class (Foo.java)
> you could then refer to the component in a html-file (to save space);
>
> test.html
>
>
> <span jwcid="@foo" bar="Hello World!"/>
>
>
> That _should_ work and is a very small template of how to connect things
> to
> self-made components. When you say that you get the error that the
> parameter
> wasn't bound, it means just that, one or more of the required parameters
> defined for the component (in you case Phone wasn't filled when referring
> to
> it. The easiest solution is that you might have made a type either in the
> jwc file or in the page file for the page which is referring to it.
>
> Cheers,
> PS
>
> On 3/11/06, John Menke <[EMAIL PROTECTED]> wrote:
> >
> > I tried your suggest but ending up getting errors stating that
> parameters
> > were unbound.
> >
> > I thought the binding tags below bind the values on the form.  If i put
> > parameter tags on top of these declarations i get errors.  Can anyone
> show
> > me an example of what you are talking about and how to reference the
> > component in my page template?
> >
> > -jm
> >
> > <component id="phone1" type="TextField">
> >         <binding name="value" value="phone1"/>
> >
> >         <binding name="validators"
> >
> >
> value="validators:required[%invalid-area-code],pattern=\d{3}[%invalid-area-code]"/>
> >
> >
> >     </component>
> >     <component id="phone2" type="TextField">
> >         <binding name="value" value="phone2"/>
> >         <binding name="validators"
> >
> >
> value="validators:required[%invalid-phone-num],pattern=\d{3}[%invalid-phone-num]"/>
> >
> >
> >     </component>
> >     <component id="phone3" type="TextField">
> >         <binding name="value" value="phone3"/>
> >         <binding name="validators"
> >
> >
> value="validators:required[%invalid-phone-num],pattern=\d{4}[%invalid-phone-num]"/>
> >
> >     </component>
> >
> >
> >
> >
> >
> >
> >
> >
> > On 3/10/06, Peter Svensson <[EMAIL PROTECTED]> wrote:
> > >
> > > Hmm. OK. You have to have a parameter definition in your component.
> > that's
> > > what accepts the bindings to it you make in the page file where you
> > refer
> > > to
> > > it, like;
> > >
> > > <parameter name="phone1" required="yes"/>
> > > ..
> > > etc..
> > >
> > > in the Phone.jwc file
> > >
> > > Cheers,
> > > PS
> > >
> > >
> > > On 3/10/06, John Menke <[EMAIL PROTECTED]> wrote:
> > > >
> > > > Peter,
> > > >
> > > > I have getter and setter methods in my Phone.java and in my Parent
> > file
> > > > NestedPhoneTest.java
> > > >
> > > > here: is what i have
> > > >
> > > > TestNestedPhone.page:
> > > >
> > > >
> > > >     <component id="Phone" type="Phone">
> > > >
> > > >       <binding name="phone1" value="ognl:
> components.form.phone.phone1
> > "/>
> > > >       <binding name="phone2"  value="ognl:
> components.form.phone.phone1
> > > "/>
> > > >       <binding name="phone3"  value="ognl:
> components.form.phone.phone1
> > > "/>
> > > >
> > > >     </component>
> > > >
> > > >
> > > > Phone.jwc:
> > > >
> > > > <component id="phone1" type="TextField">
> > > >         <binding name="value" value="phone1"/>
> > > >         <binding name="validators"
> > > >
> > > >
> > >
> >
> value="validators:required[%invalid-area-code],pattern=\d{3}[%invalid-area-code]"/>
> > > >
> > > >     </component>
> > > >     <component id="phone2" type="TextField">
> > > >         <binding name="value" value="phone2"/>
> > > >         <binding name="validators"
> > > >
> > > >
> > >
> >
> value="validators:required[%invalid-phone-num],pattern=\d{3}[%invalid-phone-num]"/>
> > > >
> > > >     </component>
> > > >     <component id="phone3" type="TextField">
> > > >         <binding name="value" value="phone3"/>
> > > >         <binding name="validators"
> > > >
> > > >
> > >
> >
> value="validators:required[%invalid-phone-num],pattern=\d{4}[%invalid-phone-num]"/>
> > > >
> > > >     </component>
> > > >
> > > >
> > > >      <property name="phone1"/>
> > > >     <property name="phone2"/>
> > > >     <property name="phone3"/>
> > > >
> > > >
> > > > Phone.html
> > > >
> > > >
> > > > <input jwcid="phone1" name="phone1" tabindex="80" size="3"
> > maxlength="3"
> > > > displayName="Day Phone"/>&nbsp;-
> > > >
> > > > <input jwcid="phone2" name="dayphone2" type="text" id="dayphone2ID"
> > > > tabindex
> > > > ="90" size="3" maxlength="3" displayName="Day Phone" />&nbsp;-
> > > >
> > > > <input jwcid="phone3" name="dayphone3" type="text" id="dayphone3ID"
> > > > tabindex
> > > > ="95" size="4" maxlength="4" displayName="Day Phone" />
> > > >
> > > > What i'm hoping is for in the submitAction in my
> NestedPhoneTest.javato
> > > > be
> > > > able to read the values.
> > > >
> > > > I have
> > > >
> > > >
> > > > public void formSubmit(IRequestCycle cycle) {
> > > >
> > > >              String phone1 = getPhone1();
> > > >              String phone2 = getPhone2();
> > > >              String phone3 = getPhone1();
> > > >
> > > >              System.out.println(phone1 + phone2 + phone3);
> > > >
> > > > }
> > > >
> > > > the values come out nullnullnull
> > > >
> > > > In my log i get this warning:
> > > >
> > > > 10 Mar 2006 14:56:43,765  WARN ComponentTemplateLoader:428 -
> Template
> > > for
> > > > component TestNestedPhone does not reference embedded component:
> > Phone.
> > > >
> > > > Is it my ognl binding?
> > > >
> > > >
> > > >
> > > > jm
> > > >
> > > >
> > > >
> > > > On 3/10/06, Peter Svensson <[EMAIL PROTECTED]> wrote:
> > > > >
> > > > > I think you just give them different names/ids like you already
> do.
> > > And
> > > > > since you have named the values already, you need only add some
> > > abstrcat
> > > > > access methods in your class,like;
> > > > >
> > > > > public abstract String getPhone1();
> > > > > public void setPhone1(String s);
> > > > >
> > > > > And you're done :)
> > > > >
> > > > > I don't think that the "type"  actually does anything, possibly
> not
> > > the
> > > > id
> > > > > in the html either.
> > > > >
> > > > > Generally, I'd recommend you to either do all in html or just name
> > the
> > > > > component in the jwcid="" tag and then do everything
> kraftwerk-style
> > > in
> > > > > the
> > > > > .page file.
> > > > >
> > > > > Cheers,
> > > > > PS
> > > > >
> > > > >
> > > > > On 3/10/06, John Menke <[EMAIL PROTECTED]> wrote:
> > > > > >
> > > > > > I want to write a "Phone" component that allows me to define 3
> > text
> > > > > input
> > > > > > boxes contained inside it:
> > > > > >
> > > > > > My question is:  How can can i bind/retrieve the values in my
> > > > containing
> > > > > > page and how do I avoid name conflicts if i have more than 1
> Phone
> > > > > > component
> > > > > > on the containing page?
> > > > > >
> > > > > > Phone.html
> > > > > >
> > > > > > <html>
> > > > > >
> > > > > > <body jwcid="$content$">
> > > > > >
> > > > > > <input jwcid="phone1" name="phone1" tabindex="80" size="3"
> > > > maxlength="3"
> > > > > > displayName="Day Phone"/>&nbsp;-
> > > > > >
> > > > > > <input jwcid="phone2" name="dayphone2" type="text"
> > id="dayphone2ID"
> > > > > > tabindex
> > > > > > ="90" size="3" maxlength="3" displayName="Day Phone" />&nbsp;-
> > > > > >
> > > > > > <input jwcid="phone3" name="dayphone3" type="text"
> > id="dayphone3ID"
> > > > > > tabindex
> > > > > > ="95" size="4" maxlength="4" displayName="Day Phone" />
> > > > > >
> > > > > > </body>
> > > > > >
> > > > > > </html>
> > > > > >
> > > > > > Phone.jwc
> > > > > >
> > > > > >
> > > > > > <component-specification allow-body="no">
> > > > > >
> > > > > >    <component id="phone1" type="TextField">
> > > > > >         <binding name="value" value="phone1"/>
> > > > > >     </component>
> > > > > >     <component id="phone2" type="TextField">
> > > > > >         <binding name="value" value="phone2"/>
> > > > > >       </component>
> > > > > >     <component id="phone3" type="TextField">
> > > > > >         <binding name="value" value="phone3"/>
> > > > > >     </component>
> > > > > > </component-specification>
> > > > > >
> > > > > > **
> > > > > >
> > > > > > -jm
> > > > > >
> > > > > >
> > > > >
> > > > >
> > > >
> > > >
> > >
> > >
> >
> >
>
>

Reply via email to