You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by bhorvat <ho...@gmail.com> on 2012/10/06 13:25:26 UTC
Generating unique tapestry id or client id in HighCharts
Hi I am trying to use the HighChart component in the loop but with not luck
so far. My problem is that the client id is always the same for everything
that runs in the loop but if I put the few components next to each other
then they all have the unique id. The code in the class that comes from the
component (not under my control)
@Parameter(value = "prop:componentResources.id", defaultPrefix =
BindingConstants.LITERAL)
private String clientId;
@Parameter
private JSONObject options;
@Inject
private JavaScriptSupport javascript;
@Inject
private ComponentResources resources;
@SetupRender
public void addDiv(MarkupWriter writer){
writer.element("div", "id", clientId);
}
@AfterRender
public void setJS(MarkupWriter writer){
resources.renderInformalParameters(writer);
writer.end();
JSONObject opt = new JSONObject();
opt.put("id", clientId);
JSONObject params = getComponentOptions();
JQueryUtils.merge(params, options);
opt.put("opt", params);
System.out.println(opt);
javascript.addInitializerCall("highcharts", opt);
}
public JSONObject getComponentOptions(){
return new JSONObject();
}
public String getClientId() {
return clientId;
}
So my problem is that
@SetupRender
public void addDiv(MarkupWriter writer){
writer.element("div", "id", clientId);
}
generates writes always the same id. So how can I override this class or
supply an external id vie parameter so that it is unique. What would be the
best way?
I guess I could create a method that sets this id and then pass it to the
component but I would like to avoid creating an extra method as I belive
that this is something that component it self should resolve, any
suggestions?
--
View this message in context: http://tapestry.1045711.n5.nabble.com/Generating-unique-tapestry-id-or-client-id-in-HighCharts-tp5716693.html
Sent from the Tapestry - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: Generating unique tapestry id or client id in HighCharts
Posted by bhorvat <ho...@gmail.com>.
tnx for info I will see what I can about the pull request.
cheers
--
View this message in context: http://tapestry.1045711.n5.nabble.com/Generating-unique-tapestry-id-or-client-id-in-HighCharts-tp5716693p5716810.html
Sent from the Tapestry - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: Generating unique tapestry id or client id in HighCharts
Posted by Lance Java <la...@googlemail.com>.
The HighCharts component should call
JavaScriptSupport.allocateClientId(clientId) to generate a unique id. Since
you don't have control over the class, you'll either need to pass in a
unique clientId parameter or fork the project and send the owner a pull
request.
--
View this message in context: http://tapestry.1045711.n5.nabble.com/Generating-unique-tapestry-id-or-client-id-in-HighCharts-tp5716693p5716702.html
Sent from the Tapestry - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org