admin管理员组文章数量:1208155
I have 3 questions:
Each and every action in Vaadin makes a call to the server. is there a way to avoid calls to server for every actions? like having a code at client side for particular actions that is used many times? Like in CSValidation add-on.
I want to know how to add Javascript/JQuery in Vaadin 7. It seems easy in Vaadin 6. But, I couldn't get it working in Vaadin 7. I hope they would have made it more easy now. Can anyone show me some examples regarding this. If it is JQuery, It will help me a lot.
And also will
Javascript.getCurrent().execute("");
'execute the javascript' or 'add specified script' in to the code. Will this help me to solve my 2nd question?
I have 3 questions:
Each and every action in Vaadin makes a call to the server. is there a way to avoid calls to server for every actions? like having a code at client side for particular actions that is used many times? Like in CSValidation add-on.
I want to know how to add Javascript/JQuery in Vaadin 7. It seems easy in Vaadin 6. But, I couldn't get it working in Vaadin 7. I hope they would have made it more easy now. Can anyone show me some examples regarding this. If it is JQuery, It will help me a lot.
And also will
Javascript.getCurrent().execute("");
'execute the javascript' or 'add specified script' in to the code. Will this help me to solve my 2nd question?
Share Improve this question edited Jul 3, 2013 at 5:21 David Hofmann 5,77512 gold badges53 silver badges79 bronze badges asked Jun 20, 2013 at 15:19 Gugan MohanGugan Mohan 1,6452 gold badges28 silver badges65 bronze badges 2- Someone please answer this.. – Gugan Mohan Commented Jun 24, 2013 at 4:58
- any fiddle or Code will help to answer.. If possible please provide.. – MarmiK Commented Jun 27, 2013 at 7:41
2 Answers
Reset to default 16 +501) Each and every action in Vaadin makes a call to the server. Is there a way to avoid calls to server for every actions? like having a code at client side for particular actions that is used many times? Like in CSValidation add-on.
This depends on the client-side code. Vaadin is built with a server side programming model, but if you need to restrict the amount of server calls, you need to do it yourself. Vaadin 7 made it relatively easier to include third party libraries as it was in Vaadin 6.
2) I want to know how to add Javascript/JQuery in Vaadin 7. It seems easy in Vaadin 6. But, I couldn't get it working in Vaadin 7. I hope they would have made it more easy now. Can anyone show me some examples regarding this. If it is JQuery, It will help me a lot.
Here you have a nice tutorial on how to integrate jQuery with Vaadin 7: http://java.dzone.com/articles/integrating-html-and-0
It basically goes about creating a JavascriptExtension class, this is the main part of the solution:
@JavaScript({ "https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.js" })
public class JavascriptJQueryExtension extends AbstractJavaScriptExtension {
... // Please see the link above for an example of implementation
}
The path can either be an URL or an internal path to the jQuery library.
3) 'execute the javascript' or 'add specified script' in to the code.
The following code snippet will be executed, as stated in the Book of Vaadin 7 (https://vaadin.com/book/vaadin7/-/page/advanced.javascript.html)
// Shorthand
JavaScript.getCurrent().execute("alert('Hello')");
The JavaScript is executed after the server request that is currently processed returns. (...)
I would suggest for you to take a good look at the Book of Vaadin. It contains a lot of important information that is usually helpful to solve most of the problems that arise when working with Vaadin.
I am not expert of Vaadin Framework...
I can tell you that your Question No.3 is to run JavaScript commands through that..
You can also run jQuery command through that..
But for that you must have jQuery included in the page..
for Question 1: I can say it is possible, as Vaadin have the functionality that overrides function..
JavaScript.getCurrent().addFunction("com.example.foo.myfunc",
new JavaScriptFunction() {
@Override
public void call(JSONArray arguments) throws JSONException {
Notification.show("Received call");
}
});
Link link = new Link("Send Message", new ExternalResource(
"javascript:com.example.foo.myfunc()"));
Now in absence of supporting code, you must identify the actual plugin's function that is making call to server on each action. Make sure if you override the function.. you will require that functionality at some point.. so do not override the actually required function....
Question 2,
yes the jQuery is available with vaadin, refer forum
it says you can call jQuery directly like this $wnd.JQuery
I hope this will help...
本文标签: javaAdd javascriptJquery amp client side code in Vaadin 7Stack Overflow
版权声明:本文标题:java - Add javascriptJquery & client side code in Vaadin 7 - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1738686478a2106849.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论