[英]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.