简体   繁体   English

如何在Spring Roo生成的页面中使用自定义JavaScript?

[英]How can I use custom javascript in Spring Roo generated pages?

I have been working on a spring roo project and I've hit a wall in terms of being able to customize the web page. 我一直在从事spring roo项目,在能够自定义网页方面遇到了麻烦。

The main thing I want to do is be able to dynamically hide certain fields as the client is filling out the web form. 我要做的主要事情是能够在客户端填写Web表单时动态隐藏某些字段。 I have a drop down list driven by enumerations that has 4 options and a fifth "other" option. 我有一个由枚举驱动的下拉列表,它具有4个选项和第五个“其他”选项。 If the user selects "other" I want a text box to appear so the user can fill out their own selection. 如果用户选择“其他”,我希望出现一个文本框,以便用户填写自己的选择。

I was talking to someone and they said "This really depends on the UI you choose. In case of MVC scaffolding you can use javascript to drive these relationships". 我正在和某人交谈,他们说:“这实际上取决于您选择的UI。在MVC脚手架的情况下,您可以使用JavaScript来驱动这些关系”。 I am indeed using MVC scaffolding so I guess I have to use javascript. 我确实在使用MVC脚手架,所以我想我必须使用JavaScript。 I don't really know that much javascript but the problem lies in that I don't even know where the javascript code would go in term of my project files. 我真的不太了解javascript,但是问题在于我什至不知道就我的项目文件而言,javascript代码在哪里。 And then the second problem of course is how to use javascript to hide the fields dynamically in Spring. 然后,第二个问题当然是如何使用javascript在Spring中动态隐藏字段。

Thanks 谢谢

Spring MVC scaffolding uses dojo by default as its javascript framework. Spring MVC支架默认使用dojo作为其javascript框架。

You are able to use standard dojo functions when you attach events to DOM elements. 将事件附加到DOM元素时,就可以使用标准的dojo函数。 You can simply use the <script/> tag to contain your own custom javascript methods within a generated .jspx page. 您可以简单地使用<script/>标记在生成的.jspx页面中包含自己的自定义javascript方法。

Additionally, you can integrate another existing javascript framework such as jQuery. 此外,您可以集成另一个现有的javascript框架,例如jQuery。 At the moment you can include jQuery manually, but it can possibly be expected in a future Spring Roo version. 目前,您可以手动包含jQuery,但将来的Spring Roo版本中可能会期望它。

You can play safe with dojo for now. 您现在可以安全使用dojo。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在GVnix / Spring Roo项目中添加Javascript - How add Javascript in GVnix/Spring roo project 如何在javascript生成的表上使用“ rel”属性? - How can I use a “rel” attribute on a javascript generated table? 如何在javascript函数中使用PHP生成的JSON数组? - How can I use a JSON array generated in PHP in a javascript function? 如果我的所有页面都不相同,如何避免使用页面内Javascript并使用外部Javascript文件? - How can I avoid in-page Javascript and use external Javascript files, if all of my pages are different? 如何获取用javascript生成的HTML? - How can I get the HTML generated with javascript? 如何使用javaScript在不同页面上显示带有自定义消息的工具提示? - How can I display a tooltip with custom messages on different pages using javaScript? 如何让用户通过我的自定义域访问亚马逊s3 html / javascript页面? - How can I let users visit amazon s3 html/javascript pages through my custom domain? 如何在类似页面上运行javascript? - How can I run javascript on similar pages? 如何在javascript中使用自定义“类”(函数)作为数组数据类型? - How can I use custom “class”(function) as array datatype in javascript? 如何使用javascript自定义事件而不是while循环? - How can I use a javascript custom event instead of a while loop?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM