Spring JS is designed such that an implementation of its API can be built for any of the popular Javascript toolkits. The initial implementation of Spring.js builds on the Dojo toolkit.
Using Spring Javascript in a page requires including the underlying toolkit as normal, the Spring.js
base interface file, and the Spring-(library implementation).js
file for the underlying toolkit. As an example, the following includes obtain the Dojo implementation of Spring.js using the ResourceServlet
:
When using the widget system of an underlying library, typically you must also include some CSS resources to obtain the desired look and feel. For the booking-mvc reference application, Dojo's tundra.css
is included:
11.4. Spring Javascript Decorations
A central concept in Spring Javascript is the notion of applying decorations to existing DOM nodes. This technique is used to progressively enhance a web page such that the page will still be functional in a less capable browser. The addDecoration
method is used to apply decorations.
The following example illustrates enhancing a Spring MVC <form:input>
tag with rich suggestion behavior:
<form:input id="searchString" path="searchString"/>
<script type="text/javascript">
Spring.addDecoration(new Spring.ElementDecoration({
elementId: "searchString",
widgetType: "dijit.form.ValidationTextBox",
widgetAttrs: { promptMessage : "Search hotels by name, address, city, or zip." }}));
</script>
The ElementDecoration
is used to apply rich widget behavior to an existing DOM node. This decoration type does not aim to completely hide the underlying toolkit, so the toolkit's native widget type and attributes are used directly. This approach allows you to use a common decoration model to integrate any widget from the underlying toolkit in a consistent manner. See the booking-mvc
reference application for more examples of applying decorations to do things from suggestions to client-side validation.
When using the ElementDecoration
to apply widgets that have rich validation behavior, a common need is to prevent the form from being submitted to the server until validation passes. This can be done with the ValidateAllDecoration
:
<input type="submit" id="proceed" name="_eventId_proceed" value="Proceed" />
<script type="text/javascript">
Spring.addDecoration(new Spring.ValidateAllDecoration({ elementId:'proceed', event:'onclick' }));
</script>
This decorates the "Proceed" button with a special onclick event handler that fires the client side validators and does not allow the form to submit until they pass successfully.
An AjaxEventDecoration
applies a client-side event listener that fires a remote Ajax request to the server. It also auto-registers a callback function to link in the response:
<a id="prevLink" href="search?searchString=${criteria.searchString}&page=${criteria.page - 1}">Previous</a>
<script type="text/javascript">
Spring.addDecoration(new Spring.AjaxEventDecoration({
elementId: "prevLink",
event: "onclick",
params: { fragments: "body" }
}));
</script>
This decorates the onclick event of the "Previous Results" link with an Ajax call, passing along a special parameter that specifies the fragment to be re-rendered in the response. Note that this link would still be fully functional if Javascript was unavailable in the client. (See the section on Handling Ajax Requests for details on how this request is handled on the server.)
It is also possible to apply more than one decoration to an element. The following example shows a button being decorated with Ajax and validate-all submit suppression:
<input type="submit" id="proceed" name="_eventId_proceed" value="Proceed" />
<script type="text/javascript">
Spring.addDecoration(new Spring.ValidateAllDecoration({elementId:'proceed', event:'onclick'}));
Spring.addDecoration(new Spring.AjaxEventDecoration({elementId:'proceed', event:'onclick',formId:'booking', params:{fragments:'messages'}}));
</script>
It is also possible to apply a decoration to multiple elements in a single statement using Dojo's query API. The following example decorates a set of checkbox elements as Dojo Checkbox widgets:
<div id="amenities">
<form:checkbox path="amenities" value="OCEAN_VIEW" label="Ocean View" /></li>
<form:checkbox path="amenities" value="LATE_CHECKOUT" label="Late Checkout" /></li>
<form:checkbox path="amenities" value="MINIBAR" label="Minibar" /></li>
<script type="text/javascript">
dojo.query("#amenities input[type='checkbox']").forEach(function(element) {
Spring.addDecoration(new Spring.ElementDecoration({
elementId: element.id,
widgetType : "dijit.form.CheckBox",
widgetAttrs : { checked : element.checked }
}));
});
</script>
</div>
11.5. Handling Ajax Requests
Spring Javascript's client-side Ajax response handling is built upon the notion of receiving "fragments" back from the server. These fragments are just standard HTML that is meant to replace portions of the existing page. The key piece needed on the server is a way to determine which pieces of a full response need to be pulled out for partial rendering.
In order to be able to render partial fragments of a full response, the full response must be built using a templating technology that allows the use of composition for constructing the response, and for the member parts of the composition to be referenced and rendered individually. Spring Javascript provides some simple Spring MVC extensions that make use of Tiles to achieve this. The same technique could theoretically be used with any templating system supporting composition.
Spring Javascript's Ajax remoting functionality is built upon the notion that the core handling code for an Ajax request should not differ from a standard browser request, thus no special knowledge of an Ajax request is needed directly in the code and the same hanlder can be used for both styles of request.
Providing a Library-Specific AjaxHandler
The key interface for integrating various Ajax libraries with the Ajax-aware behavior of Web Flow (such as not redirecting for a partial page update) is org.springframework.js.AjaxHandler
. A SpringJavascriptAjaxHandler
is configured by default that is able to detect an Ajax request submitted via the Spring JS client-side API and can respond appropriately in the case where a redirect is required. In order to integrate a different Ajax library (be it a pure JavaScript library, or a higher-level abstraction such as an Ajax-capable JSF component library), a custom AjaxHandler
can be injected into the FlowHandlerAdapter
or FlowController
.
Handling Ajax Requests with Spring MVC Controllers
In order to handle Ajax requests with Spring MVC controllers, all that is needed is the configuration of the provided Spring MVC extensions in your Spring application context for rendering the partial response (note that these extensions require the use of Tiles for templating):
<bean id="tilesViewResolver" class="org.springframework.js.ajax.AjaxUrlBasedViewResolver">
<property name="viewClass" value="org.springframework.webflow.mvc.view.FlowAjaxTilesView"/>
</bean>
This configures the AjaxUrlBasedViewResolver
which in turn interprets Ajax requests and creates FlowAjaxTilesView
objects to handle rendering of the appropriate fragments. Note that FlowAjaxTilesView
is capable of handling the rendering for both Web Flow and pure Spring MVC requests. The fragments correspond to individual attributes of a Tiles view definition. For example, take the following Tiles view definition:
<definition name="hotels/index" extends="standardLayout">
<put-attribute name="body" value="index.body" />
</definition>
<definition name="index.body" template="/WEB-INF/hotels/index.jsp">
<put-attribute name="hotelSearchForm" value="/WEB-INF/hotels/hotelSearchForm.jsp" />
<put-attribute name="bookingsTable" value="/WEB-INF/hotels/bookingsTable.jsp" />
</definition>
An Ajax request could specify the "body", "hotelSearchForm" or "bookingsTable" to be rendered as fragments in the request.
Handling Ajax Requests with Spring MVC + Spring Web Flow
Spring Web Flow handles the optional rendering of fragments directly in the flow definition language through use of the render
element. The benefit of this approach is that the selection of fragments is completely decoupled from client-side code, such that no special parameters need to be passed with the request the way they currently must be with the pure Spring MVC controller approach. For example, if you wanted to render the "hotelSearchForm" fragment from the previous example Tiles view into a rich Javascript popup:
<view-state id="changeSearchCriteria" view="enterSearchCriteria.xhtml" popup="true">
<on-entry>
<render fragments="hotelSearchForm" />
</on-entry>
<transition on="search" to="reviewHotels">
<evaluate expression="searchCriteria.resetPage()"/>
</transition>
</view-state>
相关推荐
100道逻辑思维趣题,ajax框架:dwr》实战(包括整合),Ajax中英文对照手册,CSS2 – Quick Reference Guide,css滤镜,css样式,DHTML默认行为手册,DOM文档对象模型手册,JavaScript源码大全 v1.0,javascript资料(源码,...
- **JavaScript**:前端技术,用于实现动态效果和交互体验。 - **Ajax**:异步数据交换技术,提升用户体验。 - **CSS Framework**:预定义样式库,加快前端开发速度。 - **Maven**:项目构建工具,管理依赖、构建...
内容概要:本文详细介绍了永磁同步电机(PMSM)三闭环控制系统的仿真建模方法及其参数优化技巧。首先阐述了三闭环控制的整体架构,即位置环、速度环和电流环的层级关系,并解释了每个环节的作用。接着展示了各环的具体实现代码,如电流环的PI控制器、速度环的前馈控制以及位置环的限幅处理。文中强调了调参的重要性和注意事项,提供了具体的参数选择依据和调试建议。最后分享了一些实用的仿真技巧,如死区补偿、故障注入等,确保模型能够应对实际工况。 适合人群:从事电机控制研究的技术人员、研究生及以上水平的学生,特别是对永磁同步电机三闭环控制感兴趣的读者。 使用场景及目标:适用于需要深入了解PMSM三闭环控制原理并进行仿真实验的研究人员和技术开发者。目标是帮助读者掌握如何构建高效的三闭环控制系统,提高电机性能,降低能耗,增强系统的鲁棒性和可靠性。 其他说明:文中提供的代码片段和参数配置均基于MATLAB/Simulink平台,建议读者在实践中结合实际情况调整参数,以获得最佳效果。同时,附带的参考资料也为进一步学习提供了指导。
光电材料仿真,电子仿真等;从入门到精通教程;含代码案例解析。
内容概要:本文详细介绍了利用PFC3D5.0进行滑坡致灾与建筑物易损性分析的完整代码实现。首先,通过Python和Fish语言构建了滑坡体和建筑物的模型,设置了关键参数如密度、刚度、摩擦系数等,确保滑坡体能够真实模拟滑坡行为。其次,针对建筑物的不同部位(楼板、墙体、支柱),采用不同的材料特性进行建模,并加入了实时监测系统,用于记录滑坡过程中各部件的应力、应变以及冲击力的变化情况。此外,还实现了冲击力监测、损伤评估等功能,能够自动触发应急分析并在模拟结束后生成详细的损伤报告。最后,通过对多次模拟结果的数据处理,生成了建筑物的易损性曲线,验证了模型的有效性和准确性。 适合人群:从事地质灾害研究、土木工程、结构安全评估的研究人员和技术人员。 使用场景及目标:适用于滑坡灾害预测、建筑设计优化、抗震防灾等领域。通过模拟不同条件下滑坡对建筑物的影响,帮助研究人员更好地理解滑坡致灾机理,为制定有效的防护措施提供科学依据。 其他说明:文中提供了大量实用的小技巧,如调整参数以获得更好的模拟效果、优化计算效率等。同时强调了模型验证的重要性,确保研究成果具有较高的可信度。
编译httpserver 通过后记录的
光电材料仿真,电子仿真等;从入门到精通教程;含代码案例解析。
内容概要:本文详细探讨了在Android平台上进行图像模板匹配的技术挑战和解决方案,特别是在处理不同尺寸和旋转角度的目标物时的方法。文中介绍了使用OpenCV构建图像金字塔、处理旋转模板以及利用NEON指令集优化性能的具体实现。此外,文章还讨论了在armeabi-v7a和arm64-v8a这两种主要ARM架构下的优化技巧,如内存对齐、SIMD指令优化、RenderScript并行处理等。作者分享了许多实践经验,包括如何避免常见的性能瓶颈和兼容性问题。 适合人群:有一定Android开发经验,尤其是熟悉OpenCV和NDK编程的中级及以上开发者。 使用场景及目标:适用于需要在移动设备上进行高效图像识别的应用开发,如实时视频流中的物体检测、游戏内的道具识别等。目标是提高模板匹配的速度和准确性,同时确保在不同硬件配置下的稳定性和兼容性。 其他说明:文章提供了丰富的代码片段和实际案例,帮助读者更好地理解和应用所介绍的技术。特别强调了在不同ARM架构下的优化策略,为开发者提供了宝贵的参考资料。
光电材料仿真,电子仿真等;从入门到精通教程;含代码案例解析。
内容概要:本文详细介绍了利用COMSOL软件模拟电晕放电离子风的过程。首先解释了电晕放电的基本概念,即在高压电场下电极周围空气被电离形成离子风。接着阐述了如何在COMSOL中建立针-板电极结构的三维模型,涉及静电、层流和稀物质传递三个物理场的设置。文中提供了具体的MATLAB代码片段用于初始化模型、定义几何体、设置边界条件、配置物理参数、进行网格划分以及求解模型。此外,还讨论了求解过程中可能出现的问题及解决方法,如收敛技巧、网格划分策略等。最后强调了通过模拟获得的电场分布、气流速度和离子浓度等结果对于理解和优化电晕放电离子风设备的重要性。 适用人群:对电晕放电现象感兴趣的科研人员和技术开发者,尤其是那些希望深入了解多物理场耦合仿真技术的人群。 使用场景及目标:适用于需要研究电晕放电离子风特性的场合,如空气净化装置、散热设备等领域的产品设计与性能评估。目标是帮助用户掌握如何使用COMSOL软件构建并求解电晕放电离子风模型,从而更好地理解相关物理机制。 其他说明:文中提到的实际操作细节和遇到的技术挑战有助于新手避免常见错误,提高建模效率。同时,提供的具体参数设置和代码示例也为进一步深入研究奠定了基础。
内容概要:本文详细介绍了多模态属性级情感分析的技术原理及其应用场景。首先解释了多模态属性级情感分析的意义,即通过结合文本和图像信息来更全面地理解用户情感。接着阐述了数据预处理方法,如使用BERT进行文本编码和ResNet处理图像。然后深入探讨了模型架构,包括双流网络结构和特征融合策略,以及如何通过跨模态注意力机制实现更好的特征对齐。此外,文中还分享了多个实战案例,如电商广告投放系统中如何利用该技术提高转化率,以及在处理用户评价时遇到的问题和解决办法。最后讨论了一些常见的技术挑战,如模态间权重调整、背景干扰物处理等。 适合人群:从事自然语言处理、计算机视觉研究的专业人士,尤其是希望将这两种技术结合起来进行情感分析的研究者和技术开发者。 使用场景及目标:适用于电商平台、社交媒体平台等需要分析用户反馈的场景,旨在帮助企业更好地理解消费者的真实想法,从而优化产品和服务。通过这种方式,企业可以发现潜在的市场机会并改进营销策略。 其他说明:文章不仅提供了理论指导,还包括具体的代码实现示例,有助于读者快速上手实践。同时强调了实际应用中的注意事项,如数据清洗、模型调优等方面的经验教训。
内容概要:本文详细介绍了5MW海上永磁风电直驱系统的Simulink仿真过程,涵盖矢量控制、混合储能系统以及并网逆变器的设计与调试。首先,文章解释了系统架构,包括永磁电机、两电平并网变流器和混合储能模块。接着,深入探讨了矢量控制中的坐标变换、PI参数设置及其对电网波动的影响。对于混合储能系统,文章讨论了滑动平均滤波用于功率分配的方法,确保超级电容和锂电池的有效协同工作。此外,文章还涉及并网逆变器的控制策略,特别是变参数PI控制和死区时间补偿,以应对复杂的电网环境。最后,通过仿真结果展示了系统的高效性和稳定性。 适合人群:从事电力电子工程、风电系统设计与仿真的工程师和技术研究人员。 使用场景及目标:适用于希望深入了解海上风电系统仿真技术的专业人士,旨在提高对矢量控制、混合储能和并网逆变器的理解,从而优化实际应用中的系统性能。 其他说明:文中提供了多个MATLAB代码片段,帮助读者更好地理解和复现相关控制算法。同时,强调了仿真过程中遇到的实际问题及解决方案,如风速突变、电网电压跌落等情况下的系统响应。
光电材料仿真,电子仿真等;从入门到精通教程;含代码案例解析。
该资源为natsort-5.4.0-py2.py3-none-any.whl,欢迎下载使用哦!
内容概要:本文详细介绍了双馈风力发电机(DFIG)的矢量控制仿真模型,特别是定子侧和转子侧的控制策略。定子侧采用电压定向矢量控制,通过双闭环结构(外环控制直流侧电压,内环控制电流),确保功率因数为1。转子侧采用磁链定向矢量控制,同样基于双闭环结构(外环控制功率,内环控制电流),并引入前馈电压补偿提高响应速度。文中提供了具体的PI控制器代码实现,并讨论了仿真模型的搭建方法,如使用Python的scipy库进行动态响应模拟。此外,文章还提到了一些常见的仿真问题及解决方案,如crowbar保护电路、最大功率跟踪算法和低电压穿越模块等。 适合人群:从事风电系统设计、控制算法开发的研究人员和技术人员,以及对电力电子控制系统感兴趣的工程师。 使用场景及目标:适用于希望深入了解DFIG矢量控制原理和实现细节的专业人士,帮助他们掌握定子侧和转子侧的具体控制策略,优化仿真模型,解决实际工程中的问题。 其他说明:文章不仅提供了理论分析,还包括了大量的代码片段和实践经验,有助于读者更好地理解和应用相关技术。
内容概要:本文详细介绍了利用Python进行煤矿瓦斯气驱过程中二氧化碳和氮气的应用方法和技术细节。首先展示了如何通过Python脚本处理气驱压力监测数据并绘制对比图,接着讲解了注气速率控制的PID算法实现及其注意事项。文中还涉及裂隙气体扩散模拟、湿度对氮气驱替的影响以及基于状态机的注气控制系统设计。此外,提供了实时气体浓度监控、数据滤波、阈值报警等功能的具体实现方式,并强调了数据可视化的应用价值。最后讨论了注气孔布置优化和注气压力控制的实际操作要点。 适合人群:从事煤矿开采及相关领域的技术人员、工程师,尤其是具有一定编程基础并对自动化控制感兴趣的从业者。 使用场景及目标:适用于煤矿瓦斯气驱项目的规划、实施与维护阶段,旨在提高瓦斯抽采效率,确保安全生产,同时减少人为因素导致的操作失误。通过学习本文提供的代码示例和技术方案,读者能够掌握如何运用Python解决实际工程问题的方法。 其他说明:文中提到的所有代码均为简化版本,用于解释相关概念和技术原理,在实际项目中可能需要进一步完善和优化。对于希望深入了解该领域的读者而言,本文不仅提供了实用的技术指导,也为后续研究奠定了良好的基础。
光电材料仿真,电子仿真等;从入门到精通教程;含代码案例解析。
街道级行政区划边界,wgs84坐标系,shp数据,直接分析使用。
字节码.md
Maven.md