You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Mateus Lucio dos Santos <ma...@softtek.com> on 2007/08/10 17:32:25 UTC

Create a custom checkbox component

Hi!
I need to display a checkbox in a webpage. This checkbox work as a node 
in a treeview, so i need to save in the checkbox tag which node is his 
parent and which node are his children.

I tried to simply add two attributes to the checkbox tag like this 
<input id="test" type="checkbox" parent="parent" children="children" /> 
it works just fine in I.E but firefox doesn't recognize the parent and 
children attributes, thats why i'm trying to solve this creating a 
component that has those attributes.

I'm a beginner using tapestry so i'm clueless about how to create a 
component that works the this way.
Can any one send me some material or explain me how to create this 
component?

Thanks in advance

Re: Create a custom checkbox component

Posted by Martino Piccinato <ma...@gmail.com>.
Yes, there's a "value" parameter you can bind some page method to so
that you can easily get/set the !Object in the hidden field from the
page (you'll have to cast the object obviously).

I think you'll have all your checkboxes inside a For component so I
guess you'll iterate over a collection and have something like


<component id="userList" type="For">
<binding name="source" value="nodes"/>
<binding name="value" value="currentNode"/>
</component>

<component id="nodeCheckBox" type="Checkbox">
<binding name="value" value="currentNode.selected"/>
</component>

<component id="nodeParent" type="Hidden">
<binding name="value" value="currentNode.parent"/>
</component>

<component id="nodeChild" type="Hidden">
<binding name="value" value="currentNode.child"/>
</component>



Well I think guessed too much but as you haven't provided much information :-)

Depending on your model and on what you have to achieve things could
be even simpler as maybe you already have parent/child informations in
node itself

On 8/10/07, Mateus Lucio dos Santos <ma...@softtek.com> wrote:
> I like the idea!!
> But when the browser render this component will I be able to access
> those attributes?
>
> Martino Piccinato wrote:
> > I think you could just make a component using a normal checkbox PLUS
> > two Hidden components (
> > http://tapestry.apache.org/tapestry4.1/components/form/hidden.html)
> > containing the parent/child references.
> >
> > Just extend BaseComponent and use one Checkbox plus two Hidden in your
> > new component.
> >
> > Adding strange, non standard, attributes to tags your browsers will
> > see is never a good idea :-)
> >
> > On 8/10/07, Mateus Lucio dos Santos <ma...@softtek.com> wrote:
> >
> >> Hi!
> >> I need to display a checkbox in a webpage. This checkbox work as a node
> >> in a treeview, so i need to save in the checkbox tag which node is his
> >> parent and which node are his children.
> >>
> >> I tried to simply add two attributes to the checkbox tag like this
> >> <input id="test" type="checkbox" parent="parent" children="children" />
> >> it works just fine in I.E but firefox doesn't recognize the parent and
> >> children attributes, thats why i'm trying to solve this creating a
> >> component that has those attributes.
> >>
> >> I'm a beginner using tapestry so i'm clueless about how to create a
> >> component that works the this way.
> >> Can any one send me some material or explain me how to create this
> >> component?
> >>
> >> Thanks in advance
> >>
> >>
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> > For additional commands, e-mail: users-help@tapestry.apache.org
> >
> >
> >
>
>

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


Re: Create a custom checkbox component

Posted by Mateus Lucio dos Santos <ma...@softtek.com>.
I like the idea!!
But when the browser render this component will I be able to access 
those attributes?

Martino Piccinato wrote:
> I think you could just make a component using a normal checkbox PLUS
> two Hidden components (
> http://tapestry.apache.org/tapestry4.1/components/form/hidden.html)
> containing the parent/child references.
>
> Just extend BaseComponent and use one Checkbox plus two Hidden in your
> new component.
>
> Adding strange, non standard, attributes to tags your browsers will
> see is never a good idea :-)
>
> On 8/10/07, Mateus Lucio dos Santos <ma...@softtek.com> wrote:
>   
>> Hi!
>> I need to display a checkbox in a webpage. This checkbox work as a node
>> in a treeview, so i need to save in the checkbox tag which node is his
>> parent and which node are his children.
>>
>> I tried to simply add two attributes to the checkbox tag like this
>> <input id="test" type="checkbox" parent="parent" children="children" />
>> it works just fine in I.E but firefox doesn't recognize the parent and
>> children attributes, thats why i'm trying to solve this creating a
>> component that has those attributes.
>>
>> I'm a beginner using tapestry so i'm clueless about how to create a
>> component that works the this way.
>> Can any one send me some material or explain me how to create this
>> component?
>>
>> Thanks in advance
>>
>>     
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>
>   


Re: Create a custom checkbox component

Posted by Martino Piccinato <ma...@gmail.com>.
I think you could just make a component using a normal checkbox PLUS
two Hidden components (
http://tapestry.apache.org/tapestry4.1/components/form/hidden.html)
containing the parent/child references.

Just extend BaseComponent and use one Checkbox plus two Hidden in your
new component.

Adding strange, non standard, attributes to tags your browsers will
see is never a good idea :-)

On 8/10/07, Mateus Lucio dos Santos <ma...@softtek.com> wrote:
> Hi!
> I need to display a checkbox in a webpage. This checkbox work as a node
> in a treeview, so i need to save in the checkbox tag which node is his
> parent and which node are his children.
>
> I tried to simply add two attributes to the checkbox tag like this
> <input id="test" type="checkbox" parent="parent" children="children" />
> it works just fine in I.E but firefox doesn't recognize the parent and
> children attributes, thats why i'm trying to solve this creating a
> component that has those attributes.
>
> I'm a beginner using tapestry so i'm clueless about how to create a
> component that works the this way.
> Can any one send me some material or explain me how to create this
> component?
>
> Thanks in advance
>

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