Reputation: 5031
I'm working with tapestry 5.2.6, and I try to call à javascript from my java code (based on some processing), This is my java code:
@Mixin
private Dialog alert;
@Inject
private JavaScriptSupport javaScriptSupport;
void callJavaScript() {
alert.initializeClient(WindowStyle.GREYLIGHTING);
javaScriptSupport.addScript("G2.alert('%s', {width:500, height:80, className:'bluelighting'});",
"Congratulations Tarik");
}
but I have this error:
Caused by: org.apache.tapestry5.ioc.internal.OperationException: No object of type org.apache.tapestry5.services.javascript.JavaScriptSupport is available from the Environment.
Could someone help me with that error or show me how I can open that popup from my java code ?
NB: To test the callJavaScript()
function, I annotated it with @AfterRender
and then my popup appears correctly after page rendering.
Upvotes: 2
Views: 1521
Reputation: 754
Try @Environmental instead of @Inject. They both should work, but it's something to try. Technically @Environmental is more correct.
Upvotes: 0