`

s:doubleselect 与 sx:div

阅读更多

s:doubleselect 与 sx:div 结合使用,某些属性不设置会出现一些莫名的问题。sx:div这个Ajax标签的属性太多,不好好研究下它的属性而使用它会出现许多莫名的问题,其中列表选项无法联动就是比较难缠的问题。后来通过搜索发现此标签的“separateScripts”属性是其引起问题的主因!官方文档上说明了会影响Ajax标签的几个属性,如下:

 

 

 

 

Attribute Default Value Description
parseContent true When true, Dojo will parse the response into an XHTML Document Object and traverse the nodes searching for Dojo Widget markup. The parse and traversal is performed prior to inserting the nodes into the DOM. This attribute must be enabled to nest Dojo widgets (dojo tags) within responses. There's significant processing involved to create and parse the document so switch this feature off when not required. Note also that the response must be valid XHTML for cross-browser support and widgets must have unique IDs.
separateScripts true When true, Dojo will extract the <script> tags from the response, concatenate the extracted code into one block, create a new Function whose body is the extracted code and immediately invoke the function. The invocation is performed after the DOM has been updated with the XHTML. The function is executed within the scope of the widget (that is, the this variable points to the widget instance).
When false, Dojo will extract the <script> tags from the response, concatenate the extracted code into one block and:
*in IE: invoke window.execScript() on the code
*in other browsers: create a <script> node containing the code and insert that node into the DOM
This invocation occurs after the DOM has been updated with the XHTML. Note that scripts may not be executed if it is not valid to create a <script> node in the DOM at the destination.
executeScripts false When true, Dojo will extract code from the <script> tags from the response and execute it based on the separateScripts value.
When false, the XHTML response is inserted into the DOM and <script> nodes are ignored.

 

 

我们主要看 separateScripts ,其描述文字的主要大意是,如果此属性设置为“true”,Dojo会将从response中提取<script> 标签内的代码并组合到一个新建的函数,并立即调用。此属性默认就是“true”,这不是我们想要的,因此把此它设置为“false”,问题解决。

 

 

还需要注意的是executeScripts这个属性设置不好也会出现Javascript无法运行的问题,比如A.jsp文件内的标签sx:div异步引入B.html文件,此文件有一段Javascript代码,比如:<script>alert("弹出信息");<script>,若要此代码正常执行,则executeScripts属性必须设置为“true”。

 

 

 

分享到:
评论

相关推荐

    j2ee-struts2-Select_DoubleSelect.rar_struts2 doubleselect

    - `listKey`, `listValue`, `doubleListKey`, `doubleListValue`:与`s:select`标签中的含义相同,但这里用于定义主列表和子列表的键和值。 在J2EE项目中,你通常需要创建一个Action类,该类包含这些列表数据,并...

    doubleselect.doc

    为了提高用户体验并简化开发过程,Struts2框架提供了一个非常实用的标签——`&lt;s:doubleselect&gt;`。该标签可以轻松实现两个下拉列表框之间的联动效果,通常用于展示具有层级关系的数据。 本文将详细介绍如何使用...

    struts2 doubleselect 实例

    在Struts2中,`&lt;s:doubleselect&gt;`标签的主要属性包括: 1. `label`:定义了标签的显示文本。 2. `name`:定义了表单字段的名称,用于后台接收数据。 3. `list`:表示一级下拉列表的数据源,通常是一个列表或数组,...

    Strus 2的新表单标志的使用

    接下来,我们将详细介绍两个常见而又复杂的表单标签:`&lt;s:checkboxlist/&gt;` 和 `&lt;s:doubleselect/&gt;`。 #### `&lt;s:checkboxlist/&gt;` 标签详解 ##### 核心问题:默认选中某个复选框 开发者常常困惑于如何在 `&lt;s:...

    Struts2标签列表及说明

    * &lt;s:div&gt;:表示一个块,类似于 HTML 的 &lt;div&gt;&lt;/div&gt; * &lt;s:doubleselect&gt;:双下拉框 E: * &lt;s:if&gt;:条件判断 * &lt;s:elseif&gt;:条件判断 * &lt;s:else&gt;:条件判断 F: * &lt;s:fielderror&gt;:显示文件错误信息 * &lt;s:file&gt;...

    struts2 标签库 帮助文档

    4. &lt;s:div&gt;&lt;/s:div&gt;-----表示一个块,类似于html的&lt;div&gt;&lt;/div&gt; 5. &lt;s:doubleselect list="" doubleName="" doubleList=""&gt;&lt;/s:doubleselect&gt;-----双下拉框 E: 1. &lt;s:if test=""&gt;&lt;/s:if&gt; 2. &lt;s:elseif test=...

    Struts2标签详解及具体实例解析

    4. `&lt;s:div&gt;&lt;/s:div&gt;` - 块级元素,类似于HTML的`&lt;div&gt;`,用于布局和分组。 5. `&lt;s:doubleselect list="" doubleName="" doubleList=""&gt;&lt;/s:doubleselect&gt;` - 双下拉框,用于双向选择关联数据。 E部分: 1. `&lt;s:if ...

    struts2地市、县区二级联动下拉菜单 doubleselect标签

    4. **JSP页面**:在JSP页面中,使用`&lt;s:doubleselect&gt;`标签来声明这两个下拉列表。标签的属性包括`list`、`listKey`、`listValue`、`name`等,它们分别用来指定数据源、键字段、值字段以及Action中的属性名。 ```...

    Struts2的doubleselect标签演示

    4. **OGNL表达式**:在JSP页面中,我们可以使用OGNL表达式来获取Action中的属性,如`&lt;s:doubleselect&gt;`标签中的`list`、`listKey`、`listValue`等属性,都需要通过OGNL来绑定Action中的数据。 5. **`doubleselect`...

    struts2.0 taglib 标签库

    - `&lt;s:div&gt;`:创建一个HTML的`&lt;div&gt;`块。 - `&lt;s:push&gt;`:将值推入栈中,便于`&lt;s:property&gt;`标签获取。 7. **输入与输出标签**: - `&lt;s:date&gt;`:格式化日期。 - `&lt;s:datetimepicker&gt;`:日期时间选择器。 - `&lt;s:...

     strut2 标签详解

    4. `&lt;s:div&gt;`:创建一个块级元素,相当于HTML的`&lt;div&gt;`。 5. `&lt;s:doubleselect&gt;`:双列选择框,用于两个下拉列表之间的数据关联。 E组标签: 1. `&lt;s:if&gt;`、`&lt;s:elseif&gt;`、`&lt;s:else&gt;`:条件判断标签,实现条件语句。...

    struts2标签大全详解

    4. `&lt;s:div&gt;`:创建一个类似HTML的`&lt;div&gt;`标签,用于布局。 5. `&lt;s:doubleselect&gt;`:创建双列选择框,允许用户从两个列表中选择值。 E部分: 1. `&lt;s:if&gt;`,`&lt;s:elseif&gt;`,`&lt;s:else&gt;`:条件判断语句,用于控制标签的...

    struts2标签大全

    &lt;/s:div&gt; ``` ##### 9. 双下拉框 `&lt;s:doubleselect&gt;` - **用途**:创建两个关联的下拉框。 - **示例代码**: ```xml &lt;s:doubleselect list="countries" doubleName="selectedCountry" doubleList="cities" /&gt; ...

    struts2 doubleselect标签的用法例子

    在JSP页面中,使用`&lt;s:doubleselect&gt;`标签来渲染这两个下拉列表。标签的属性包括但不限于`list`(父级选项)、`listKey`(父级选项的键)、`listValue`(父级选项的显示值)、`doubleList`(子级选项的映射)、`...

    struts2标签详解(收集).pdf

    - `&lt;s:div&gt;`:创建HTML的&lt;div&gt;元素。 - `&lt;s:doubleselect&gt;`:创建两个关联的下拉框。 - `&lt;s:elseif&gt;`、`&lt;s:else&gt;`:进行条件判断。 - `&lt;s:fielderror&gt;`:显示字段级别的错误信息。 - `&lt;s:file&gt;`:处理文件上传。 这...

    struts2.0 标签清单

    `&lt;s:div&gt;` 标签 `&lt;s:div&gt;` 标签用于创建一个HTML的`&lt;div&gt;`元素,可以包含其他HTML或Struts2标签,用于布局设计。 ### 12. `&lt;s:doubleselect&gt;` 标签 `&lt;s:doubleselect&gt;` 标签用于创建双列表选择框,允许用户从一...

    struts2标签介绍

    4. `&lt;s:div&gt;` - 创建一个块元素,相当于HTML的`&lt;div&gt;`,常用于样式和布局。 5. `&lt;s:doubleselect&gt;` - 双列选择框,用于两个关联的下拉列表。 **E组标签:** 1. `&lt;s:if&gt;`, `&lt;s:elseif&gt;`, `&lt;s:else&gt;` - 条件判断标签...

    Struts2标签应用.

    4. `&lt;s:div&gt;`:相当于HTML的`&lt;div&gt;`,用于创建块级元素。 5. `&lt;s:doubleselect&gt;`:创建两个关联的下拉框,用于一对多的选择。 E部分: 1. `&lt;s:if&gt;`、`&lt;s:elseif&gt;`、`&lt;s:else&gt;`:条件判断标签,用于根据表达式结果...

Global site tag (gtag.js) - Google Analytics