You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Muhammad Mohsen <m....@gmail.com> on 2011/06/25 13:53:25 UTC

Change how beaneditor structures it's fields

Hello everyone,

I've been searching for a while but I'm facing difficulties solving this
situation.

I have a page. This page contains a form component, then this form embeds
multiple beaneditor components.
I need to change how a specific beaneditor component of these renders it's
fields. I found that the beaneditor puts each of it's input fields and label
in one div element which causes the fields to be rendered vertically.

I just need to put some fields in one div element so that they are rendered
next to each other.

Here is my page's code:

public class ConfigureTclTest {
    @Component
    private Form configureTclTest;
    @Property
    private boolean overridePortParameters;
    @Component
    private BeanEditor commonTestDataEditor; //The editor can work without
this declaration. But this is my current version.
    @Property
    private CommonTestData commonTestData;
    .
    .
    .
    }

My tml file:
<t:form t:id="configureTclTest">
    <h2>Chassis information</h2>
    <div class="t-beaneditor-row">
        <label for="overridePortParameters">Override</label>
        <t:checkbox t:id="overridePortParameters" />
    </div>
    <t:beaneditor t:id="commonTestDataEditor" object="commonTestData"
exclude="chassisIp">
        <t:parameter name="ipAddress">
            <t:label for="ipAddress" />
            <t:textfield t:id="ipAddress"
value="${message:default.ipAddress}" disabled="true" />
        </t:parameter>
        <t:parameter name="prefix">
            <t:label for="prefix" />
            <t:textfield t:id="prefix" value="${message:default.prefix}"
disabled="true" />
        </t:parameter>
    </t:beaneditor>
    .
    .
    .

So how should I intercept a specific event for a beaneditor located as
mentioned above ?
According to my understanding of event bubbling, should I handle event for
the form component instead ?
Moreover, as I understand that at some point I'll use the MarkupWriter
interface. I have no clear idea about how it behaves.

Am I clear explaining this ?

If the needed is mentioned somewhere, links will be enough.
Thanks a lot in advance :)

-- 
*Regards,*
*Muhammad Gelbana
Java Developer*

Re: Change how beaneditor structures it's fields

Posted by Muhammad Gelbana <m....@gmail.com>.
>
> Again, you can't handle render events from other components.
>
I was just trying to explain the solution I tried to implement.
I'll look into mixins then.

Thank you Robert and Thiago :)

On Fri, Jul 1, 2011 at 11:27 PM, Thiago H. de Paula Figueiredo <
thiagohp@gmail.com> wrote:

> On Fri, 01 Jul 2011 18:03:25 -0300, Muhammad Gelbana <m....@gmail.com>
> wrote:
>
>  The thing is that beaneditor encapsulates each rendered field in a div tag
>> and I need to put more than one field in a single div tag so I need to
>> handle the BeginRender event for the beaneditor.
>>
>
> Again, you can't handle render events from other components. A component or
> page class can only render its own render events. I guess your solution will
> be to write a mixin and apply it to BeanEditor. And it will need to handle
> the AfterRender, not the BeginRender one, which is triggered, obviouslly,
> before BeanEditor starts rendering.
>
>
>  My case summerized, I have a beaneditor located inside a form (in the tml
>> file). That form is in a page and I need to control who the fields tags
>> are rendered by the bean.
>>
>
> Grid, BeanEditor, BeanEditForm and BeanDisplay aren't meant to cover every
> single scenario.
> You can always declare the form field components yourself if BeanEditor
> doesn't match what you want. Or provide your own template snippet for these
> two fields.
>
>
> --
> Thiago H. de Paula Figueiredo
> Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,
> and instructor
> Owner, Ars Machina Tecnologia da Informação Ltda.
> http://www.arsmachina.com.br
>
> ------------------------------**------------------------------**---------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.**apache.org<us...@tapestry.apache.org>
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>


-- 
*Regards,*
*Muhammad Gelbana
Java Developer*

Re: Change how beaneditor structures it's fields

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
On Fri, 01 Jul 2011 18:03:25 -0300, Muhammad Gelbana <m....@gmail.com>  
wrote:

> The thing is that beaneditor encapsulates each rendered field in a div  
> tag and I need to put more than one field in a single div tag so I need  
> to
> handle the BeginRender event for the beaneditor.

Again, you can't handle render events from other components. A component  
or page class can only render its own render events. I guess your solution  
will be to write a mixin and apply it to BeanEditor. And it will need to  
handle the AfterRender, not the BeginRender one, which is triggered,  
obviouslly, before BeanEditor starts rendering.

> My case summerized, I have a beaneditor located inside a form (in the tml
> file). That form is in a page and I need to control who the fields tags  
> are rendered by the bean.

Grid, BeanEditor, BeanEditForm and BeanDisplay aren't meant to cover every  
single scenario.
You can always declare the form field components yourself if BeanEditor  
doesn't match what you want. Or provide your own template snippet for  
these two fields.

-- 
Thiago H. de Paula Figueiredo
Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,  
and instructor
Owner, Ars Machina Tecnologia da Informação Ltda.
http://www.arsmachina.com.br

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


Re: Change how beaneditor structures it's fields

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
On Fri, 01 Jul 2011 17:12:52 -0300, Muhammad Gelbana <m....@gmail.com>  
wrote:

> Failure parsing template
>> classpath:com/skycomm/tclagent/pages/ConfigureTclTest.tml: Block  
>> parameters
>> are only allowed directly within component elements.

The message is quite descriptive . . .

> So I still can't get to make this work. You know even if this worked I  
> still wanna know why can't I handle the beaneditor events such as the  
> BeginRender event. I'm all about getting a hang of tapestry and not just  
> getting this to work.

BeanEditor doesn't trigger any events. You can only handle events like  
BeginRender (render events) in the same component or page.

-- 
Thiago H. de Paula Figueiredo
Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,  
and instructor
Owner, Ars Machina Tecnologia da Informação Ltda.
http://www.arsmachina.com.br

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


Re: Change how beaneditor structures it's fields

Posted by Muhammad Gelbana <m....@gmail.com>.
Sorry for the late reply but sadly I only get to work on tapestry only on my
weekend :(

Thanks Robert for your help but this won't work as the following exception
is being thrown:

Failure parsing template
> classpath:com/skycomm/tclagent/pages/ConfigureTclTest.tml: Block parameters
> are only allowed directly within component elements.
>

So I still can't get to make this work. You know even if this worked I still
wanna know why can't I handle the beaneditor events such as the BeginRender
event. I'm all about getting a hang of tapestry and not just getting this to
work.

Thanks again :)

On Sat, Jun 25, 2011 at 9:04 PM, Robert Zeigler <robert.zeigler@roxanemy.com
> wrote:

> Beaneditor is nice, but not meant as a catch-all. What I would probably do
> is beanedit the properties above the custom needs, then directly insert the
> fields you need, then beanedit the rest. Like:
>
> <beaneditor object="myobj" include="a,b"/>
> <div><t:textfield .../><t:textfield .../></div>
> <beaneditor object="myobj" include="e,f"/>
>
> Robert
>
> GATAATGCTATTTCTTTAATTTTCGAA
>
> On Jun 25, 2011, at 6:53 AM, Muhammad Mohsen <m....@gmail.com> wrote:
>
> > Hello everyone,
> >
> > I've been searching for a while but I'm facing difficulties solving this
> > situation.
> >
> > I have a page. This page contains a form component, then this form embeds
> > multiple beaneditor components.
> > I need to change how a specific beaneditor component of these renders
> it's
> > fields. I found that the beaneditor puts each of it's input fields and
> label
> > in one div element which causes the fields to be rendered vertically.
> >
> > I just need to put some fields in one div element so that they are
> rendered
> > next to each other.
> >
> > Here is my page's code:
> >
> > public class ConfigureTclTest {
> >    @Component
> >    private Form configureTclTest;
> >    @Property
> >    private boolean overridePortParameters;
> >    @Component
> >    private BeanEditor commonTestDataEditor; //The editor can work without
> > this declaration. But this is my current version.
> >    @Property
> >    private CommonTestData commonTestData;
> >    .
> >    .
> >    .
> >    }
> >
> > My tml file:
> > <t:form t:id="configureTclTest">
> >    <h2>Chassis information</h2>
> >    <div class="t-beaneditor-row">
> >        <label for="overridePortParameters">Override</label>
> >        <t:checkbox t:id="overridePortParameters" />
> >    </div>
> >    <t:beaneditor t:id="commonTestDataEditor" object="commonTestData"
> > exclude="chassisIp">
> >        <t:parameter name="ipAddress">
> >            <t:label for="ipAddress" />
> >            <t:textfield t:id="ipAddress"
> > value="${message:default.ipAddress}" disabled="true" />
> >        </t:parameter>
> >        <t:parameter name="prefix">
> >            <t:label for="prefix" />
> >            <t:textfield t:id="prefix" value="${message:default.prefix}"
> > disabled="true" />
> >        </t:parameter>
> >    </t:beaneditor>
> >    .
> >    .
> >    .
> >
> > So how should I intercept a specific event for a beaneditor located as
> > mentioned above ?
> > According to my understanding of event bubbling, should I handle event
> for
> > the form component instead ?
> > Moreover, as I understand that at some point I'll use the MarkupWriter
> > interface. I have no clear idea about how it behaves.
> >
> > Am I clear explaining this ?
> >
> > If the needed is mentioned somewhere, links will be enough.
> > Thanks a lot in advance :)
> >
> > --
> > *Regards,*
> > *Muhammad Gelbana
> > Java Developer*
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>


-- 
*Regards,*
*Muhammad Gelbana
Java Developer*

Re: Change how beaneditor structures it's fields

Posted by Robert Zeigler <ro...@roxanemy.com>.
Beaneditor is nice, but not meant as a catch-all. What I would probably do is beanedit the properties above the custom needs, then directly insert the fields you need, then beanedit the rest. Like:

<beaneditor object="myobj" include="a,b"/>
<div><t:textfield .../><t:textfield .../></div>
<beaneditor object="myobj" include="e,f"/>

Robert

GATAATGCTATTTCTTTAATTTTCGAA

On Jun 25, 2011, at 6:53 AM, Muhammad Mohsen <m....@gmail.com> wrote:

> Hello everyone,
> 
> I've been searching for a while but I'm facing difficulties solving this
> situation.
> 
> I have a page. This page contains a form component, then this form embeds
> multiple beaneditor components.
> I need to change how a specific beaneditor component of these renders it's
> fields. I found that the beaneditor puts each of it's input fields and label
> in one div element which causes the fields to be rendered vertically.
> 
> I just need to put some fields in one div element so that they are rendered
> next to each other.
> 
> Here is my page's code:
> 
> public class ConfigureTclTest {
>    @Component
>    private Form configureTclTest;
>    @Property
>    private boolean overridePortParameters;
>    @Component
>    private BeanEditor commonTestDataEditor; //The editor can work without
> this declaration. But this is my current version.
>    @Property
>    private CommonTestData commonTestData;
>    .
>    .
>    .
>    }
> 
> My tml file:
> <t:form t:id="configureTclTest">
>    <h2>Chassis information</h2>
>    <div class="t-beaneditor-row">
>        <label for="overridePortParameters">Override</label>
>        <t:checkbox t:id="overridePortParameters" />
>    </div>
>    <t:beaneditor t:id="commonTestDataEditor" object="commonTestData"
> exclude="chassisIp">
>        <t:parameter name="ipAddress">
>            <t:label for="ipAddress" />
>            <t:textfield t:id="ipAddress"
> value="${message:default.ipAddress}" disabled="true" />
>        </t:parameter>
>        <t:parameter name="prefix">
>            <t:label for="prefix" />
>            <t:textfield t:id="prefix" value="${message:default.prefix}"
> disabled="true" />
>        </t:parameter>
>    </t:beaneditor>
>    .
>    .
>    .
> 
> So how should I intercept a specific event for a beaneditor located as
> mentioned above ?
> According to my understanding of event bubbling, should I handle event for
> the form component instead ?
> Moreover, as I understand that at some point I'll use the MarkupWriter
> interface. I have no clear idea about how it behaves.
> 
> Am I clear explaining this ?
> 
> If the needed is mentioned somewhere, links will be enough.
> Thanks a lot in advance :)
> 
> -- 
> *Regards,*
> *Muhammad Gelbana
> Java Developer*

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