You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Davide Vecchi <dv...@amc.dk> on 2015/09/18 09:58:31 UTC

Make Tapestry add an id to the tag of the grid
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 ?

Re: Make Tapestry add an id to the

tag of the gridPosted by Thiago H de Paula Figueiredo <th...@gmail.com>.
On Tue, 22 Sep 2015 06:18:32 -0300, Davide Vecchi <dv...@amc.dk> 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: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


RE: Make Tapestry add an id to the

tag of the gridPosted by Davide Vecchi <dv...@amc.dk>.
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 <us...@tapestry.apache.org>
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".

--


Re: Make Tapestry add an id to the

tag of the gridPosted by Thiago H de Paula Figueiredo <th...@gmail.com>.
On Mon, 21 Sep 2015 11:36:52 -0300, Davide Vecchi <dv...@amc.dk> 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: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


RE: Make Tapestry add an id to the

tag of the gridPosted by Davide Vecchi <dv...@amc.dk>.
>> 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.

Re: Make Tapestry add an id to the

tag of the gridPosted by Thiago H de Paula Figueiredo <th...@gmail.com>.
On Fri, 18 Sep 2015 04:58:31 -0300, Davide Vecchi <dv...@amc.dk> 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: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


RE: Make Tapestry add an id to the

tag of the gridPosted by Davide Vecchi <dv...@amc.dk>.
By the way is TAP5-1569 ( https://issues.apache.org/jira/browse/TAP5-1569 ) the fix for this issue ?

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


Re: Make Tapestry add an id to the

tag of the gridPosted by Thiago H de Paula Figueiredo <th...@gmail.com>.
> -----Original Message-----
> From: Svein-Erik Løken
> Sent: Monday, September 21, 2015 08:54
> To: users@tapestry.apache.org
> 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: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


RE: Make Tapestry add an id to the

tag of the gridPosted by Davide Vecchi <dv...@amc.dk>.
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: users@tapestry.apache.org
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 <sv...@jacilla.no>
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: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org

RE: Make Tapestry add an id to the

tag of the gridPosted by Svein-Erik Løken <sv...@jacilla.no>.
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

From: Geoff Callender-2 [via Apache Tapestry Mailing List Archives] [mailto:ml-node+s1045711n5731255h86@n5.nabble.com]
Sent: 19. september 2015 05:19
To: Svein-Erik Løken <sv...@jacilla.no>
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

> On 18 Sep 2015, at 7:18 pm, Davide Vecchi <[hidden email]</user/SendEmail.jtp?type=node&node=5731255&i=0>> 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]</user/SendEmail.jtp?type=node&node=5731255&i=1>
> 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]</user/SendEmail.jtp?type=node&node=5731255&i=2>
> For additional commands, e-mail: [hidden email]</user/SendEmail.jtp?type=node&node=5731255&i=3>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]</user/SendEmail.jtp?type=node&node=5731255&i=4>
For additional commands, e-mail: [hidden email]</user/SendEmail.jtp?type=node&node=5731255&i=5>


________________________________
If you reply to this email, your message will be added to the discussion below:
http://apache-tapestry-mailing-list-archives.1045711.n5.nabble.com/Make-Tapestry-add-an-id-to-the-table-tag-of-the-grid-tp5731247p5731255.html
To unsubscribe from users@tapestry.apache.org<ma...@tapestry.apache.org> Mailing List Archives, click here<http://apache-tapestry-mailing-list-archives.1045711.n5.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=2375125&code=c3ZlaW5AamFjaWxsYS5ub3wyMzc1MTI1fC0xNTM4NzY2ODg4>.
NAML<http://apache-tapestry-mailing-list-archives.1045711.n5.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>

Re: Make Tapestry add an id to the

tag of the gridPosted by Geoff Callender <ge...@gmail.com>.
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 <dv...@amc.dk> 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: users@tapestry.apache.org
> 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: 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: Make Tapestry add an id to the

tag of the gridPosted by Davide Vecchi <dv...@amc.dk>.
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: users@tapestry.apache.org
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: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


RE: Make Tapestry add an id to the

tag of the gridPosted by Svein-Erik Løken <sv...@jacilla.no>.
In zone I am using data-id:


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

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

I think you can do the same!


From: Davide Vecchi [via Apache Tapestry Mailing List Archives] [mailto:ml-node+s1045711n5731247h38@n5.nabble.com]
Sent: 18. september 2015 09:59
To: Svein-Erik Løken <sv...@jacilla.no>
Subject: Make Tapestry add an id to the <table> tag of the grid

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 ?
________________________________
If you reply to this email, your message will be added to the discussion below:
http://apache-tapestry-mailing-list-archives.1045711.n5.nabble.com/Make-Tapestry-add-an-id-to-the-table-tag-of-the-grid-tp5731247.html
To unsubscribe from users@tapestry.apache.org<ma...@tapestry.apache.org> Mailing List Archives, click here<http://apache-tapestry-mailing-list-archives.1045711.n5.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=2375125&code=c3ZlaW5AamFjaWxsYS5ub3wyMzc1MTI1fC0xNTM4NzY2ODg4>.
NAML<http://apache-tapestry-mailing-list-archives.1045711.n5.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>

RE: Make Tapestry add an id to the

tag of the gridPosted by Davide Vecchi <dv...@amc.dk>.
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 <us...@tapestry.apache.org>
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: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: Make Tapestry add an id to the

tag of the gridPosted by "mailinglist@j-b-s.de" <ma...@j-b-s.de>.
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 <dv...@amc.dk>:
> 
> 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: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org