Make Tapestry add an id to the <table> tag of the grid

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

Make Tapestry add an id to the <table> tag of the grid

Davide Vecchi
Hi everybody,

I have the same need described in the thread at http://apache-tapestry-mailing-list-archives.1045711.n5.nabble.com/How-to-add-table-id-into-the-Grid-td2417082.html : although in my .tml I do have a t:id attribute in the <t:grid> tag, the resulting HTML does not have an id attribute in the corresponding <table> tag, so I cannot select the table through jQuery or retrieve it through JavaScript; I cannot assume that the page has only one grid so I need the <table> tag to have an id.

I am using Tapestry 5.3.7. In the above mentioned thread the guy asked how to report a bug about this issue but he got no reply. Is that fix already implemented in some newer version or is it planned to be implemented in future ? Or is there some known workaround to get the <table> tag to have an id attribute in other ways ?
Reply | Threaded
Open this post in threaded view
|

Re: Make Tapestry add an id to the <table> tag of the grid

Jens Breitenstein
Hi!

You asked for a workaround...why not using a css class temporarily until this issue is properly resolved?

class="your-id-1"

You can use a placeholder to dynamically provide different id's (well, css classes) per grid.

At least a jquery selector will now be able to pick it up and I am aware of the fact using class to mimique ID's is generally wrong...

Jens



Von meinem iPhone gesendet

> Am 18.09.2015 um 09:58 schrieb Davide Vecchi <[hidden email]>:
>
> Hi everybody,
>
> I have the same need described in the thread at http://apache-tapestry-mailing-list-archives.1045711.n5.nabble.com/How-to-add-table-id-into-the-Grid-td2417082.html : although in my .tml I do have a t:id attribute in the <t:grid> tag, the resulting HTML does not have an id attribute in the corresponding <table> tag, so I cannot select the table through jQuery or retrieve it through JavaScript; I cannot assume that the page has only one grid so I need the <table> tag to have an id.
>
> I am using Tapestry 5.3.7. In the above mentioned thread the guy asked how to report a bug about this issue but he got no reply. Is that fix already implemented in some newer version or is it planned to be implemented in future ? Or is there some known workaround to get the <table> tag to have an id attribute in other ways ?

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

Reply | Threaded
Open this post in threaded view
|

RE: Make Tapestry add an id to the <table> tag of the grid

Svein-2
In reply to this post by Davide Vecchi
CONTENTS DELETED
The author has deleted this message.
Reply | Threaded
Open this post in threaded view
|

RE: Make Tapestry add an id to the <table> tag of the grid

Davide Vecchi
In reply to this post by Jens Breitenstein
Hi, thanks for the suggestion. It's a good option, I will have to slightly twist it because the <table> tags already have a class - namely class="t-data-grid" -  but I can add multiple class names there and jQuery should be able to pick them up. Good idea.


-----Original Message-----
Sent: Friday, September 18, 2015 10:12
To: Tapestry users <[hidden email]>
Subject: Re: Make Tapestry add an id to the <table> tag of the grid

Hi!

You asked for a workaround...why not using a css class temporarily until this issue is properly resolved?

class="your-id-1"

You can use a placeholder to dynamically provide different id's (well, css classes) per grid.

At least a jquery selector will now be able to pick it up and I am aware of the fact using class to mimique ID's is generally wrong...

Jens



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

Reply | Threaded
Open this post in threaded view
|

RE: Make Tapestry add an id to the <table> tag of the grid

Davide Vecchi
In reply to this post by Svein-2
Thanks, it sounds interesting. I will have to find out what the data-id "does" in Tapestry in general though, and whether it's already used for something else in this web app, because I don't want to interfer with other functionalities. So far I couldn't find much info about data-id but I will definitely keep this as a possible option.

-----Original Message-----
From: Svein-Erik Løken
Sent: Friday, September 18, 2015 10:16
To: [hidden email]
Subject: RE: Make Tapestry add an id to the <table> tag of the grid

In zone I am using data-id:


Eg: <t:select data-id="typeSelect"

$("select[data-id='typeSelect']")

I think you can do the same!

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

Reply | Threaded
Open this post in threaded view
|

RE: Make Tapestry add an id to the <table> tag of the grid

Davide Vecchi
By the way is TAP5-1569 ( https://issues.apache.org/jira/browse/TAP5-1569 ) the fix for this issue ?

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

Reply | Threaded
Open this post in threaded view
|

Re: Make Tapestry add an id to the <table> tag of the grid

JumpStart
In reply to this post by Davide Vecchi
Tapestry does generate some “data" attributes, eg. data-validate, data-update-zone, data-async-trigger, and data-dismiss-url; but data-id is not one of them. Svein added data-id himself, but he could have called it anything so long as its name doesn’t clash with a Tapestry-generated one.

For anyone unfamiliar with “data” attributes, here’s some good info:

        http://webdesign.tutsplus.com/tutorials/all-you-need-to-know-about-the-html5-data-attribute--webdesign-9642

> On 18 Sep 2015, at 7:18 pm, Davide Vecchi <[hidden email]> wrote:
>
> Thanks, it sounds interesting. I will have to find out what the data-id "does" in Tapestry in general though, and whether it's already used for something else in this web app, because I don't want to interfer with other functionalities. So far I couldn't find much info about data-id but I will definitely keep this as a possible option.
>
> -----Original Message-----
> From: Svein-Erik Løken
> Sent: Friday, September 18, 2015 10:16
> To: [hidden email]
> Subject: RE: Make Tapestry add an id to the <table> tag of the grid
>
> In zone I am using data-id:
>
>
> Eg: <t:select data-id="typeSelect"
>
> $("select[data-id='typeSelect']")
>
> I think you can do the same!
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>


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

Reply | Threaded
Open this post in threaded view
|

RE: Make Tapestry add an id to the <table> tag of the grid

Svein-2
CONTENTS DELETED
The author has deleted this message.
Reply | Threaded
Open this post in threaded view
|

RE: Make Tapestry add an id to the <table> tag of the grid

Davide Vecchi
Thanks guys for the info about data-id; I will probably go for it, I think it's the cleanest too. But before doing so I need to figure out whether this issue would be solved by upgrading to Tapestry 5.4 which contains TAP5-1569 ( https://issues.apache.org/jira/browse/TAP5-1569 ), in case that turns out to be the fix for the missing id in the <table> tag. This might turn out to be the reason we needed to decide to upgrade to the latest Tapestry version.

An alternative workaround I am considering is to first retrieve the outer div that contains the table instead of retrieving the table itself, since Tapestry already gives that div an id. Then retrieve the first child of the div which is a table; but this creates a dependency on this outer div being there wrapping the table, which I imagine is not guaranteed to stay the same in future versions, so the data-id solution is probably better anyway.


-----Original Message-----
From: Svein-Erik Løken
Sent: Monday, September 21, 2015 08:54
To: [hidden email]
Subject: RE: Make Tapestry add an id to the <table> tag of the grid

I think data-id is cleaner than setting some class attributes. I use class attributes for style/css.

What if tapesty used data-tapestry-id internally t:id=""? Users could then use the id="" attribute directly from javascript for elements in zones.

S-E

-----Original Message-----
From: Geoff Callender-2 [via Apache Tapestry Mailing List Archives]
Sent: 19. september 2015 05:19
To: Svein-Erik Løken <[hidden email]>
Subject: Re: Make Tapestry add an id to the <table> tag of the grid

Tapestry does generate some “data" attributes, eg. data-validate, data-update-zone, data-async-trigger, and data-dismiss-url; but data-id is not one of them. Svein added data-id himself, but he could have called it anything so long as its name doesn’t clash with a Tapestry-generated one.

For anyone unfamiliar with “data” attributes, here’s some good info:

        http://webdesign.tutsplus.com/tutorials/all-you-need-to-know-about-the-html5-data-attribute--webdesign-9642


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

Re: Make Tapestry add an id to the <table> tag of the grid

Thiago H de Paula Figueiredo
In reply to this post by Davide Vecchi
On Fri, 18 Sep 2015 04:58:31 -0300, Davide Vecchi <[hidden email]> wrote:

> Hi everybody,

Hi!

>
> I have the same need described in the thread at  
> http://apache-tapestry-mailing-list-archives.1045711.n5.nabble.com/How-to-add-table-id-into-the-Grid-td2417082.html 
> : although in my .tml I do have a t:id attribute in the <t:grid> tag,

t:id and id are different. t:id is the Tapestry component id in the  
template. id is the HTML client-side id. Try <t:grid t:id="yourWantedId"  
id="yourWantedId">. Grid has the @SupportsInformalParameters, so it should  
work.

--
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]

Reply | Threaded
Open this post in threaded view
|

Re: Make Tapestry add an id to the <table> tag of the grid

Thiago H de Paula Figueiredo
In reply to this post by Davide Vecchi
> -----Original Message-----
> From: Svein-Erik Løken
> Sent: Monday, September 21, 2015 08:54
> To: [hidden email]
> Subject: RE: Make Tapestry add an id to the <table> tag of the grid
>
> What if tapesty used data-tapestry-id internally t:id=""? Users could  
> then use the id="" attribute directly from javascript for elements in  
> zones.

This is up to each component to decide. There's no single place in  
Tapestry to implement this behavior.

--
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]

Reply | Threaded
Open this post in threaded view
|

RE: Make Tapestry add an id to the <table> tag of the grid

Davide Vecchi
In reply to this post by Thiago H de Paula Figueiredo
>> t:id and id are different. t:id is the Tapestry component id in the template. id is the HTML client-side id. Try <t:grid t:id="yourWantedId"  
>> id="yourWantedId">. Grid has the @SupportsInformalParameters, so it should work.

Whoops, I see my confusion, thanks for clearing that up.

I just tried to add

id="grid1"

to the <t:grid tag, like

<t:grid
        ....
        t:id="grid1"
        id="grid1"
        ....

 but I get

org.apache.tapestry5.ioc.util.UnknownValueException: Class [my page class] does not contain a property (or public field) named 'grid1'.

However I also realized that a solution where I need to modify all the templates of pages that contain grids won't do. I need the Grid component itself to generate a client-side id in the client HTML and provide a way for my page classes to know this id. I hope there is a way to do so and then I will see if I can extend / compose / customize the Grid component to do that.

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

Re: Make Tapestry add an id to the <table> tag of the grid

Thiago H de Paula Figueiredo
On Mon, 21 Sep 2015 11:36:52 -0300, Davide Vecchi <[hidden email]> wrote:

> <t:grid
> ....
> t:id="grid1"
> id="grid1"
> ....
>
>  but I get
>
> org.apache.tapestry5.ioc.util.UnknownValueException: Class [my page  
> class] does not contain a property (or public field) named 'grid1'.

Full stack trace please. This is very weird. Until there, try  
id="literal:grid1".

--
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]

Reply | Threaded
Open this post in threaded view
|

RE: Make Tapestry add an id to the <table> tag of the grid

Davide Vecchi
Thanks Thiago, actually your original advice works great when I test it in a clean new test page with a simple grid. I do get the id attribute in the <table> tag and no ecxeption. I don't even need to add the "literal:" prefix.

The exception I mentioned only occurs from my actual page which has a lot of custom code which is probably doing something wrong with the several grids it uses. In fact not only does that page throw the exception I mentioned when I add "id= grid1"; if I change that into "literal:id=grid1" it does not add any id to the generated <table> tag. But if I try the same with a clean new test page everything works as expected. So I must conclude that some of our customizations are interfering with normal grid behavior.

So putting an "id=...." attribute in the <t:grid> tag works perfectly. However as I recently realized it would be much better for me to use a solution where I don't need to change all the tml files of pages containing grids. It would be already better for me if I could add that id from the Java code of each page instead of in the page tml, so I will look into that. As far as my original question is concerned, your advice is the solution.


-----Original Message-----
From: Thiago H de Paula Figueiredo
Sent: Monday, September 21, 2015 23:32
To: Tapestry users <[hidden email]>
Subject: Re: Make Tapestry add an id to the <table> tag of the grid

On Mon, 21 Sep 2015 11:36:52 -0300, Davide Vecchi wrote:

> <t:grid
> ....
> t:id="grid1"
> id="grid1"
> ....
>
>  but I get
>
> org.apache.tapestry5.ioc.util.UnknownValueException: Class [my page
> class] does not contain a property (or public field) named 'grid1'.

Full stack trace please. This is very weird. Until there, try id="literal:grid1".

--


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

Re: Make Tapestry add an id to the <table> tag of the grid

Thiago H de Paula Figueiredo
On Tue, 22 Sep 2015 06:18:32 -0300, Davide Vecchi <[hidden email]> wrote:

> Thanks Thiago, actually your original advice works great when I test it  
> in a clean new test page with a simple grid. I do get the id attribute  
> in the <table> tag and no ecxeption.

Yay! :)

> I don't even need to add the "literal:" prefix.

I just suggested that because of that weird exception. As I supposed,  
something else was trying to use that as if it was a property.

> So putting an "id=...." attribute in the <t:grid> tag works perfectly.  
> However as I recently realized it would be much better for me to use a  
> solution where I don't need to change all the tml files of pages  
> containing grids. It would be already better for me if I could add that  
> id from the Java code of each page instead of in the page tml, so I will  
> look into that.

The easiest way of adding some behavior to all instances of a given  
component is to add a class transformation (ComponentClassTransformWorker  
interface implementation) and use the  
MutableComponentModel.addMixinClassName(String className) to apply a mixin  
to it. This mixin will implement the behavior you want.

--
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]