How to Use Image as Form Submit Button That Has OnSelectedFrom Handler in Page Class

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

How to Use Image as Form Submit Button That Has OnSelectedFrom Handler in Page Class

Net Dawg
I have the following submit button that works great:

<t:submit t:id="pdf" name="Run Report" value="Run Report" />

with an onSelectedFromPdf() method in page class that references component id "pdf".

Question:  How can this submit button be changed from just "Run Report" to an image? 

I tried:

<input id="pdf" type="image" src="${context:layout/images/pdf_download.jpg}" />

which gives the error that "id Pdf does not exist".

And also:

<t:submit t:id="pdf" t:image="${context:layout/images/pdf_download.jpg}" />

which would be great if it worked!  But gives error:

Failure reading parameter 'image' of component ...: Could not find a coercion from type java.lang.String to type org.apache.tapestry5.Asset.
Reply | Threaded
Open this post in threaded view
|

Re: How to Use Image as Form Submit Button That Has OnSelectedFrom Handler in Page Class

nquirynen
Hi,

As you can see in the Tapestry documentation of the Submit component:
http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/corelib/components/Submit.html
and what your stacktrace is teeling you is that the "image" parameter
expects an object of the type " org.apache.tapestry5.Asset" and not just
a String.

You can add to your page class the following:

@Property
@Inject
@Path("context:layout/images/pdf_download.jpg")
private Asset pdfDownloadImage;

and in your .tml file:

<t:submit t:id="pdf" t:image="pdfDownloadImage" />


On 06/06/14 08:17, Net Dawg wrote:

> I have the following submit button that works great:
>
> <t:submit t:id="pdf" name="Run Report" value="Run Report" />
>
> with an onSelectedFromPdf() method in page class that references component id "pdf".
>
> Question:  How can this submit button be changed from just "Run Report" to an image?  
>
> I tried:
>
> <input id="pdf" type="image" src="${context:layout/images/pdf_download.jpg}" />
>
> which gives the error that "id Pdf does not exist".
>
> And also:
>
> <t:submit t:id="pdf" t:image="${context:layout/images/pdf_download.jpg}" />
>
> which would be great if it worked!  But gives error:
>
> Failure reading parameter 'image' of component ...: Could not find a coercion from type java.lang.String to type org.apache.tapestry5.Asset.

Reply | Threaded
Open this post in threaded view
|

Re: How to Use Image as Form Submit Button That Has OnSelectedFrom Handler in Page Class

JumpStart
Here are some more examples:

T5.4: http://jumpstart.doublenegative.com.au/jumpstart7/examples/styling/linksandsubmits1

T5.3: http://jumpstart.doublenegative.com.au/jumpstart/examples/styling/linksandsubmits1


On 6 Jun 2014, at 4:55 pm, Nathan Quirynen <[hidden email]> wrote:

> Hi,
>
> As you can see in the Tapestry documentation of the Submit component:
> http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/corelib/components/Submit.html
> and what your stacktrace is teeling you is that the "image" parameter
> expects an object of the type " org.apache.tapestry5.Asset" and not just
> a String.
>
> You can add to your page class the following:
>
> @Property
> @Inject
> @Path("context:layout/images/pdf_download.jpg")
> private Asset pdfDownloadImage;
>
> and in your .tml file:
>
> <t:submit t:id="pdf" t:image="pdfDownloadImage" />
>
>
> On 06/06/14 08:17, Net Dawg wrote:
>> I have the following submit button that works great:
>>
>> <t:submit t:id="pdf" name="Run Report" value="Run Report" />
>>
>> with an onSelectedFromPdf() method in page class that references component id "pdf".
>>
>> Question:  How can this submit button be changed from just "Run Report" to an image?  
>>
>> I tried:
>>
>> <input id="pdf" type="image" src="${context:layout/images/pdf_download.jpg}" />
>>
>> which gives the error that "id Pdf does not exist".
>>
>> And also:
>>
>> <t:submit t:id="pdf" t:image="${context:layout/images/pdf_download.jpg}" />
>>
>> which would be great if it worked!  But gives error:
>>
>> Failure reading parameter 'image' of component ...: Could not find a coercion from type java.lang.String to type org.apache.tapestry5.Asset.
>


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: How to Use Image as Form Submit Button That Has OnSelectedFrom Handler in Page Class

Net Dawg
Thanks!



On Thursday, June 5, 2014 10:18 PM, Geoff Callender <[hidden email]> wrote:
 


Here are some more examples:

T5.4: http://jumpstart.doublenegative.com.au/jumpstart7/examples/styling/linksandsubmits1

T5.3: http://jumpstart.doublenegative.com.au/jumpstart/examples/styling/linksandsubmits1


On 6 Jun 2014, at 4:55 pm, Nathan Quirynen <[hidden email]> wrote:

> Hi,
>
> As you can see in the Tapestry documentation of the Submit component:
> http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/corelib/components/Submit.html
> and what your stacktrace is teeling you is that the "image" parameter
> expects an object of the type " org.apache.tapestry5.Asset" and not just
> a String.
>
> You can add to your page class the following:
>
> @Property
> @Inject
> @Path("context:layout/images/pdf_download.jpg")
> private Asset pdfDownloadImage;
>
> and in your .tml file:
>
> <t:submit t:id="pdf" t:image="pdfDownloadImage" />
>
>
> On 06/06/14 08:17, Net Dawg wrote:
>> I have the following submit button that works great:
>>
>> <t:submit t:id="pdf" name="Run Report" value="Run Report" />
>>
>> with an onSelectedFromPdf() method in page class that references component id "pdf".
>>
>> Question:  How can this submit button be changed from just "Run Report" to an image? 
>>
>> I tried:
>>
>> <input id="pdf" type="image" src="${context:layout/images/pdf_download.jpg}" />
>>
>> which gives the error that "id Pdf does not exist".
>>
>> And also:
>>
>> <t:submit t:id="pdf" t:image="${context:layout/images/pdf_download.jpg}" />
>>
>> which would be great if it worked!  But gives error:
>>
>> Failure reading parameter 'image' of component ...: Could not find a coercion from type java.lang.String to type org.apache.tapestry5.Asset.
>


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]
Reply | Threaded
Open this post in threaded view
|

Re: How to Use Image as Form Submit Button That Has OnSelectedFrom Handler in Page Class

Thiago H de Paula Figueiredo
In reply to this post by Net Dawg
On Fri, 06 Jun 2014 03:17:15 -0300, Net Dawg <[hidden email]>  
wrote:

> <t:submit t:id="pdf" t:image="${context:layout/images/pdf_download.jpg}"  
> />
> which would be great if it worked!  But gives error:
>
> Failure reading parameter 'image' of component ...: Could not find a  
> coercion from type java.lang.String to type org.apache.tapestry5.Asset.

Never, never, never ever use ${} expansions when passing parameters. In  
100% of the time, it's either useless (when the parameter is a String) or  
wrong (when it's not). It should have been  
t:image="context:layout/images/pdf_download.jpg".

--
Thiago H. de Paula Figueiredo
Tapestry, Java and Hibernate consultant and developer
http://machina.com.br

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]