Links and stuff

View: New views
4 Messages — Rating Filter:   Alert me  

Links and stuff

by El Acuariano :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi all,
first of all, thanks Alejandro for your help last time. Haven't tried all your tips, had to prioritize ;) But the most important stuff I needed worked like a charm.

Now I have a couple of new problems that maybe have a simpler solution:

- I added a method to make a PDF file of an invoice. I would like to show a link to the PDF in the invoice description page. To do this I would add a pdfLink property to the Invoice class and add Edit page for the Invoice where I would add an edition block for the pdfLink and show the property as a link. Is this the recommended approach or is there a simpler way?

- I would like to access the messages bundle from code. For example, if the pdfLink property above isn't set, I would like to show a localized "no PDF file" message instead of the property null value. Is there a standard way of doing this? Can I access the messages bundle in the Invoice class getPdfLink method and return the localized message when the field is null?

Regards,
Hernán

Re: Links and stuff

by Alejandro Scandroli-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Hernán

In Trails 1.2 the ObjectForm will render its body (if a form body
exists), so there is no need to add property to the model, just add
the tapestry code directly in the body of the ObjectForm and Trails
will render it.

There is no way to access the message bundle from the model, you can
access it from any spring service or from a tapestry page.

Spring example:
        <bean id="descriptorInternationalizationAspect"
class="org.trails.i18n.DescriptorInternationalization"
factory-method="aspectOf">
                <property name="trailsMessageSource" ref="trailsMessageSource"/>
        </bean>

Tapestry example:
        @InjectObject("service:trails.core.MessageSource")
        TrailsMessageSource getResourceBundleMessageSource();

You can also use Tapestry's default i18n mechanism:
http://tapestry.apache.org/tapestry4.1/usersguide/localization.html

In the end your code could look something like this:

        <form jwcid="@trails:ObjectForm" model="ognl:model">
                <span jwcid="@If" condition="ognl:model != NULL AND model.SOMETHING != null">
                        <a href="DOWNLOAD_LINK_HERE">DOWLOAD INVOICES PDF</a>
                </span><span jwcid="@Else">
                        <p><span key="THERE_IS_NO_PDF_MESSAGE_KEY"/></p>
                </span>
        </form>


Saludos.
Alejandro.


On Tue, Jan 13, 2009 at 4:48 PM, El Acuariano <acuariano@...> wrote:

> Hi all,
> first of all, thanks Alejandro for your help last time. Haven't tried all
> your tips, had to prioritize ;) But the most important stuff I needed worked
> like a charm.
> Now I have a couple of new problems that maybe have a simpler solution:
> - I added a method to make a PDF file of an invoice. I would like to show a
> link to the PDF in the invoice description page. To do this I would add a
> pdfLink property to the Invoice class and add Edit page for the Invoice
> where I would add an edition block for the pdfLink and show the property as
> a link. Is this the recommended approach or is there a simpler way?
> - I would like to access the messages bundle from code. For example, if the
> pdfLink property above isn't set, I would like to show a localized "no PDF
> file" message instead of the property null value. Is there a standard way of
> doing this? Can I access the messages bundle in the Invoice class getPdfLink
> method and return the localized message when the field is null?
> Regards,
> Hernán

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email



Re: Links and stuff

by El Acuariano :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Thanks Alejandro!
I'm starting to get a feeling of what developing with Trails feels like and I like it! 
But I'm afraid all need a good look into Tapestry. Any recommended readings? Something oriented for an experienced Java programmer that is already familiar with the web development big picture (in contrast to the classic step-by-step example book).

On Wed, Jan 14, 2009 at 10:14 PM, Alejandro Scandroli <ascandroli@...> wrote:
Hi Hernán

In Trails 1.2 the ObjectForm will render its body (if a form body
exists), so there is no need to add property to the model, just add
the tapestry code directly in the body of the ObjectForm and Trails
will render it.

There is no way to access the message bundle from the model, you can
access it from any spring service or from a tapestry page.

Spring example:
       <bean id="descriptorInternationalizationAspect"
class="org.trails.i18n.DescriptorInternationalization"
factory-method="aspectOf">
               <property name="trailsMessageSource" ref="trailsMessageSource"/>
       </bean>

Tapestry example:
       @InjectObject("service:trails.core.MessageSource")
       TrailsMessageSource getResourceBundleMessageSource();

You can also use Tapestry's default i18n mechanism:
http://tapestry.apache.org/tapestry4.1/usersguide/localization.html

In the end your code could look something like this:

       <form jwcid="@trails:ObjectForm" model="ognl:model">
               <span jwcid="@If" condition="ognl:model != NULL AND model.SOMETHING != null">
                       <a href="DOWNLOAD_LINK_HERE">DOWLOAD INVOICES PDF</a>
               </span><span jwcid="@Else">
                       <p><span key="THERE_IS_NO_PDF_MESSAGE_KEY"/></p>
               </span>
       </form>


Saludos.
Alejandro.


On Tue, Jan 13, 2009 at 4:48 PM, El Acuariano <acuariano@...> wrote:
> Hi all,
> first of all, thanks Alejandro for your help last time. Haven't tried all
> your tips, had to prioritize ;) But the most important stuff I needed worked
> like a charm.
> Now I have a couple of new problems that maybe have a simpler solution:
> - I added a method to make a PDF file of an invoice. I would like to show a
> link to the PDF in the invoice description page. To do this I would add a
> pdfLink property to the Invoice class and add Edit page for the Invoice
> where I would add an edition block for the pdfLink and show the property as
> a link. Is this the recommended approach or is there a simpler way?
> - I would like to access the messages bundle from code. For example, if the
> pdfLink property above isn't set, I would like to show a localized "no PDF
> file" message instead of the property null value. Is there a standard way of
> doing this? Can I access the messages bundle in the Invoice class getPdfLink
> method and return the localized message when the field is null?
> Regards,
> Hernán

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

   http://xircles.codehaus.org/manage_email




Re: Links and stuff

by Alejandro Scandroli-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi

The only book on T4 is Kent Tong's Enjoying Web Development with
Tapestry (http://www.agileskills2.org/EWDT/), but even tough it has a
good depth in T4 concepts, it's exactly what you don't like: a classic
step-by-step example book. It even has screenshots of every single
configuration window in eclipse.
Beginning POJOs also covers T4, but only superficially.

I think the best option is the T4 documentation on the Tapestry site
and then some hacking in its source code.

Saludos.
Alejandro.

On Thu, Jan 15, 2009 at 2:24 AM, El Acuariano <acuariano@...> wrote:

> Thanks Alejandro!
> I'm starting to get a feeling of what developing with Trails feels like and
> I like it!
> But I'm afraid all need a good look into Tapestry. Any recommended readings?
> Something oriented for an experienced Java programmer that is already
> familiar with the web development big picture (in contrast to the classic
> step-by-step example book).
> On Wed, Jan 14, 2009 at 10:14 PM, Alejandro Scandroli
> <ascandroli@...> wrote:
>>
>> Hi Hernán
>>
>> In Trails 1.2 the ObjectForm will render its body (if a form body
>> exists), so there is no need to add property to the model, just add
>> the tapestry code directly in the body of the ObjectForm and Trails
>> will render it.
>>
>> There is no way to access the message bundle from the model, you can
>> access it from any spring service or from a tapestry page.
>>
>> Spring example:
>>        <bean id="descriptorInternationalizationAspect"
>> class="org.trails.i18n.DescriptorInternationalization"
>> factory-method="aspectOf">
>>                <property name="trailsMessageSource"
>> ref="trailsMessageSource"/>
>>        </bean>
>>
>> Tapestry example:
>>        @InjectObject("service:trails.core.MessageSource")
>>        TrailsMessageSource getResourceBundleMessageSource();
>>
>> You can also use Tapestry's default i18n mechanism:
>> http://tapestry.apache.org/tapestry4.1/usersguide/localization.html
>>
>> In the end your code could look something like this:
>>
>>        <form jwcid="@trails:ObjectForm" model="ognl:model">
>>                <span jwcid="@If" condition="ognl:model != NULL AND
>> model.SOMETHING != null">
>>                        <a href="DOWNLOAD_LINK_HERE">DOWLOAD INVOICES
>> PDF</a>
>>                </span><span jwcid="@Else">
>>                        <p><span key="THERE_IS_NO_PDF_MESSAGE_KEY"/></p>
>>                </span>
>>        </form>
>>
>>
>> Saludos.
>> Alejandro.
>>
>>
>> On Tue, Jan 13, 2009 at 4:48 PM, El Acuariano <acuariano@...> wrote:
>> > Hi all,
>> > first of all, thanks Alejandro for your help last time. Haven't tried
>> > all
>> > your tips, had to prioritize ;) But the most important stuff I needed
>> > worked
>> > like a charm.
>> > Now I have a couple of new problems that maybe have a simpler solution:
>> > - I added a method to make a PDF file of an invoice. I would like to
>> > show a
>> > link to the PDF in the invoice description page. To do this I would add
>> > a
>> > pdfLink property to the Invoice class and add Edit page for the Invoice
>> > where I would add an edition block for the pdfLink and show the property
>> > as
>> > a link. Is this the recommended approach or is there a simpler way?
>> > - I would like to access the messages bundle from code. For example, if
>> > the
>> > pdfLink property above isn't set, I would like to show a localized "no
>> > PDF
>> > file" message instead of the property null value. Is there a standard
>> > way of
>> > doing this? Can I access the messages bundle in the Invoice class
>> > getPdfLink
>> > method and return the localized message when the field is null?
>> > Regards,
>> > Hernán
>>
>> ---------------------------------------------------------------------
>> To unsubscribe from this list, please visit:
>>
>>    http://xircles.codehaus.org/manage_email
>>
>>
>
>

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email