You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Brian Lough <bk...@comcast.net> on 2008/07/01 02:47:36 UTC
Re: Creating new components on the fly in T5 using AJAX/JSON
You can. Adding a contributer to BeanBlockSource for a given property
will allow you to "check" if it should be displayed, and if so, generate
the html markup to display or present the input for the given property.
IMHO, since most [other] framework coders just "hide" whatever property
they don't want to change, or visa-versa, it's easier to go with the
<t:if test=""> [exclude what you don't want]</t:if>.
Again, depending upon whether it's input you desire to "skip" or output,
check out the source for Property[Edit|Display]Blocks.[java|tml]. It
will show you how to work the markup writer that actually creates the
htnl code.
See the TapestryModule source to determine how to contribute your own
special types based upon what you've defined via the
Property[...]Blocks.[java|tml].
The pattern expansion is basically this, for "display using
'@DataType("hours")'", for example:
AppModule.java
public static void
contributeBeanBlockSource(Configuration<BeanBlockContribution>
configuration) {
configuration.add(new BeanBlockContribution("hours",
"ApplicationDisplayBlocks", "hours", false));
}
*.pages.ApplicationDisplayBlocks.tml
<t:container xml:space="default"
xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd">
<t:block id="hours">
<t:textoutput value="hoursFormat"/>
</t:block>
</t:container>
*.pages.ApplicationDisplayBlocks.java
public String getHoursFormat() {
Double hours = (Double) context.getPropertyValue();
if (null == hours || hours.isNaN()) {
return "";
}
return String.format("%03.2f", hours);
}
The key items are the
configuration.add(new BeanBlockContribution("hours",
"ApplicationDisplayBlocks", "hours", false));
which adds to the new contribution to the chain for datatype "hours"
using "hours" block id"
<t:block id="hours">
which provides the "hours" block id.
This works for "input" as well, only the "marker" object would be used
to generate the specific html. Again, see the
PropertyEditBlocks.[java|tml] for examples.
Denis McCarthy wrote:
> Hi,
> I'm working on a somewhat complex page at the moment. This page
> consists of several input boxes that users
> fill in. I've got various onblur AJAX mixins that fire on this page
> when fields are filled in by a user. Currently, based
> on the values that users put into these text boxes, other text boxes
> and drop down select lists are either shown
> or hidden (this is done by passing simple JSON back to the page in the
> AJAX response to these blur events)
>
> Ideally, I'd like not to have these optional fields just hidden, but
> instead for the optional field to be entirely absent
> from the html markup when it's not needed, and only present when data
> entered by the user in a different field
> mandates it. Is this possible in T5? I don't think it is (because I
> think that a field needs to be present in the tml
> at page load time for the component in question to be bound to the T5
> page class), but it would be great if
> it was, as it would make the page considerably lighter size wise for
> most of my users.
> Thanks
> Denis
>
> ---------------------------------------------------------------------
> 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: Creating new components on the fly in T5 using AJAX/JSON
Posted by Denis McCarthy <dm...@annadaletech.com>.
Thanks for that - we'll hopefully get a chance to do a bit of experimentation
on this over the next few days.
2008/7/1 Brian Lough <bk...@comcast.net>:
> You can. Adding a contributer to BeanBlockSource for a given property will
> allow you to "check" if it should be displayed, and if so, generate the html
> markup to display or present the input for the given property. IMHO, since
> most [other] framework coders just "hide" whatever property they don't want
> to change, or visa-versa, it's easier to go with the <t:if test=""> [exclude
> what you don't want]</t:if>.
>
> Again, depending upon whether it's input you desire to "skip" or output,
> check out the source for Property[Edit|Display]Blocks.[java|tml]. It will
> show you how to work the markup writer that actually creates the htnl code.
> See the TapestryModule source to determine how to contribute your own
> special types based upon what you've defined via the
> Property[...]Blocks.[java|tml].
>
> The pattern expansion is basically this, for "display using
> '@DataType("hours")'", for example:
>
> AppModule.java
> public static void
> contributeBeanBlockSource(Configuration<BeanBlockContribution>
> configuration) { configuration.add(new
> BeanBlockContribution("hours", "ApplicationDisplayBlocks", "hours", false));
> }
>
> *.pages.ApplicationDisplayBlocks.tml
> <t:container xml:space="default"
> xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd">
>
> <t:block id="hours">
> <t:textoutput value="hoursFormat"/>
> </t:block>
>
> </t:container>
>
> *.pages.ApplicationDisplayBlocks.java
> public String getHoursFormat() {
> Double hours = (Double) context.getPropertyValue();
> if (null == hours || hours.isNaN()) {
> return "";
> }
> return String.format("%03.2f", hours);
> }
>
> The key items are the
> configuration.add(new BeanBlockContribution("hours",
> "ApplicationDisplayBlocks", "hours", false));
> which adds to the new contribution to the chain for datatype "hours" using
> "hours" block id"
> <t:block id="hours">
> which provides the "hours" block id.
>
> This works for "input" as well, only the "marker" object would be used to
> generate the specific html. Again, see the PropertyEditBlocks.[java|tml]
> for examples.
>
>
> Denis McCarthy wrote:
>>
>> Hi,
>> I'm working on a somewhat complex page at the moment. This page
>> consists of several input boxes that users
>> fill in. I've got various onblur AJAX mixins that fire on this page
>> when fields are filled in by a user. Currently, based
>> on the values that users put into these text boxes, other text boxes
>> and drop down select lists are either shown
>> or hidden (this is done by passing simple JSON back to the page in the
>> AJAX response to these blur events)
>>
>> Ideally, I'd like not to have these optional fields just hidden, but
>> instead for the optional field to be entirely absent
>> from the html markup when it's not needed, and only present when data
>> entered by the user in a different field
>> mandates it. Is this possible in T5? I don't think it is (because I
>> think that a field needs to be present in the tml
>> at page load time for the component in question to be bound to the T5
>> page class), but it would be great if
>> it was, as it would make the page considerably lighter size wise for
>> most of my users.
>> Thanks
>> Denis
>>
>> ---------------------------------------------------------------------
>> 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
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org