Thanks to Thiago I managed to get it to work as follows:

public class HrefLangMixin {

@InjectContainer
private ClientElement clientElement;//NEW
 @Parameter(name = "lang", required = true, defaultPrefix =
BindingConstants.LITERAL)
private String lang;

@AfterRender
public void afterRender(MarkupWriter writer) {
String id = clientElement.getClientId();//NEW
Element element = writer.getDocument().getElementById(id);//NEW
element.attribute("hreflang", lang);
}
}

Regards,
Julien.

2012/5/4 Julien Martin <bal...@gmail.com>

> Hello,
> I have the following actionLink in a tml page:
>
> <t:actionlink page="ContactUs" t:mixins="HrefLangMixin"
> t:lang="literal:fr" context="literal:fr">fr</t:actionlink>
>
> Can someone please advise how to retrieve/locate the actionLink from
> within the HrefLangMixin class?
>
> Here is what I tried but it just locate the <body> tag instead of the
> actionLink tag:
>
> public class HrefLangMixin {
>
> @Parameter(name = "lang", required = true, defaultPrefix =
> BindingConstants.LITERAL)
>  private String lang;
>
> // The code
> @AfterRender
>  public void afterRender(MarkupWriter writer) {
> Element actionLinkElem = writer.getElement();
>  actionLinkElem.attribute("hreflang", lang);
>
> }
> }
>
> Is there a trick to find my t:actionlink tag? If so what is it?
>
> Regards,
> Julien.
>

Reply via email to