iframe构件渲染成html中的iframe,除拥有html中的iframe的所有属性外,添加了服务器端API,可以动态加载页面
表 30.79. 构件信息
| Component Type | org.operamasks.faces.component.html.impl.UIIFrame |
| Component Family | org.operamasks.faces.component.html.impl.UIIFrame |
| Component Class | org.operamasks.faces.component.html.impl.UIIFrame |
| Tag Class | org.operamasks.faces.webapp.widget.UIIFrameTag |
| Renderer Type | org.operamasks.faces.component.html.impl.UIIFrame |
| Renderer Class | org.operamasks.faces.render.widget.ajax.AjaxIFrameRender |
+java.lang.Object
++javax.faces.component.UIComponent
+++javax.faces.component.UIComponentBase
++++org.operamasks.faces.component.html.base.UIIFrameBase
+++++org.operamasks.faces.component.html.impl.UIIFrame
表 30.80. 属性
| align | 定义类 | org.operamasks.faces.component.html.impl.UIIFrame | ||
| 类型 | javax.el.ValueExpression(java.lang.String) | |||
| 是否必须 | 否 | 延时求值 | 是 | |
| 构件的对齐方式 | ||||
| binding | 定义类 | javax.faces.component.UIComponentBase | ||
| 类型 | javax.el.ValueExpression(javax.faces.component.UIComponent) | |||
| 是否必须 | 否 | 延时求值 | 是 | |
| 一个值表达式,用于把该组件链接到一个ManagedBean的某个属性。 | ||||
| border | 定义类 | org.operamasks.faces.component.html.impl.UIIFrame | ||
| 类型 | javax.el.ValueExpression(java.lang.Integer) | |||
| 是否必须 | 否 | 延时求值 | 是 | |
| 构件的边框的宽度 | ||||
| frameborder | 定义类 | org.operamasks.faces.component.html.impl.UIIFrame | ||
| 类型 | javax.el.ValueExpression(java.lang.String) | |||
| 是否必须 | 否 | 延时求值 | 是 | |
| 是否显示构件边框,可选值为yes、no | ||||
| height | 定义类 | org.operamasks.faces.component.html.impl.UIIFrame | ||
| 类型 | javax.el.ValueExpression(java.lang.Integer) | |||
| 是否必须 | 否 | 延时求值 | 是 | |
| 构件的高度 | ||||
| id | 定义类 | javax.faces.component.UIComponentBase | ||
| 类型 | java.lang.String | |||
| 是否必须 | 否 | 延时求值 | 否 | |
| 这个组件的组件标识符。这个值在最近的命名容器类型的父组件范围内,必须是唯一的。 | ||||
| name | 定义类 | org.operamasks.faces.component.html.impl.UIIFrame | ||
| 类型 | javax.el.ValueExpression(java.lang.String) | |||
| 是否必须 | 否 | 延时求值 | 是 | |
| iframe的name | ||||
| onload | 定义类 | org.operamasks.faces.component.html.impl.UIIFrame | ||
| 类型 | javax.el.ValueExpression(java.lang.String) | |||
| 是否必须 | 否 | 延时求值 | 是 | |
| 在iframe的load事件触发时执行的JavaScript代码 | ||||
| rendered | 定义类 | javax.faces.component.UIComponentBase | ||
| 类型 | boolean(boolean) | |||
| 是否必须 | 否 | 延时求值 | 是 | |
| 一个标志,指出该组件是否要在任何随后的form提交过程中被渲染或处理。 这个属性的缺省值是true。 | ||||
| scrolling | 定义类 | org.operamasks.faces.component.html.impl.UIIFrame | ||
| 类型 | javax.el.ValueExpression(java.lang.String) | |||
| 是否必须 | 否 | 延时求值 | 是 | |
| 是否允许iframe内出现滚动条 | ||||
| src | 定义类 | org.operamasks.faces.component.html.base.UIIFrameBase | ||
| 类型 | javax.el.ValueExpression(java.lang.String) | |||
| 是否必须 | 否 | 延时求值 | 是 | |
| iframe中装载的页面 | ||||
| style | 定义类 | org.operamasks.faces.component.html.impl.UIIFrame | ||
| 类型 | javax.el.ValueExpression(java.lang.String) | |||
| 是否必须 | 否 | 延时求值 | 是 | |
| 构件渲染时应用到构件的CSS风格,对应于元素的style属性 | ||||
| styleClass | 定义类 | org.operamasks.faces.component.html.impl.UIIFrame | ||
| 类型 | javax.el.ValueExpression(java.lang.String) | |||
| 是否必须 | 否 | 延时求值 | 是 | |
| 构件渲染时应用到构件的CSS风格,对应于元素的class属性 | ||||
| width | 定义类 | org.operamasks.faces.component.html.impl.UIIFrame | ||
| 类型 | javax.el.ValueExpression(java.lang.Integer) | |||
| 是否必须 | 否 | 延时求值 | 是 | |
| 构件的宽度 | ||||
下面的代码设置在tabLayout的三个panel中分别加入一个iframe,通过panel的onactivate事件,改变iframe的src,详细示例可参考 bpdemos。
<layout:tabLayout id="content" tabPosition="bottom" border="false" jsvar="content">
<layout:panel title="欢迎" jsvar="contentPanel" id="contentPanel" width="100%"
style="height:100%" iconCls="demopanel-icon">
<w:iframe style="width: 100%; height: 100%;" frameborder="no"
id="contentPanelFrame" name="contentPanelFrame" onload="content.activate(contentPanel);"/>
</layout:panel>
<layout:panel title="示例详情" jsvar="detailPanel" id="detailPanel" width="100%"
style="height:100%" disabled="true" iconCls="detailpanel-icon">
<w:iframe style="width: 100%; height: 98%;" frameborder="no"
id="detailPanelFrame"/>
</layout:panel>
<layout:panel title="查看代码" id="sourcePanel" width="100%" height="100%" iconCls="sourcepanel-icon">
<w:iframe style="width: 100%; height: 100%;" frameborder="no"
id="sourcePanelFrame" />
</layout:panel>
</layout:tabLayout>Managed bean:
@ManagedBean(name = "indexBean", scope = ManagedBeanScope.REQUEST)
public class IndexBean {
...
@SaveState(timeOutAction = "refresh")
private String activatePanel = "contentPanel";
@Bind
private UIPanel contentPanel;
@Bind
private UIPanel sourcePanel;
@Bind
private UIPanel detailPanel;
@Bind
private UIPanel listPanel;
@Bind
private UIIFrame contentPanelFrame;
@Bind
private UIIFrame sourcePanelFrame;
@Bind
private UIIFrame detailPanelFrame;
@Bind
private UIIFrame listPanelFrame;
@Action
public void contentPanel_onactivate() {
activatePanel = "contentPanel";
if (contentPanelFrame.getSrc() == null
|| "".equals(contentPanelFrame.getSrc())) {
NavNode node = state.getSelectedNode();
if (node == null || node.getUrl() == null || node.getUrl().length() == 0) {
contentSrc = "/common/welcome.faces";
} else {
contentSrc = "/" + node.getUrl().replace(".", "/") + ".faces";
}
update.markAttributeUpdate(contentPanelFrame, "src");
}
}
@Action
public void detailPanel_onactivate() {
activatePanel = "detailPanel";
if (detailPanelFrame.getSrc() == null
|| "".equals(detailPanelFrame.getSrc())) {
NavNode node = state.getSelectedNode();
if (node != null && node.getDetail() != null && node.getDetail().length() > 0) {
detailPanelFrame.load(node.getDetail().replace(".", "/") + ".faces");
} else if (node != null && node.getType() == NavNode.TYPE_CASE) {
detailPanelFrame.load("/common/defaultCaseDesc.faces");
} else {
detailPanelFrame.load("/common/detail-notfound.html");
}
}
}
@Action
public void sourcePanel_onactivate() {
activatePanel = "sourcePanel";
if (sourcePanelFrame.getSrc() == null
|| sourcePanelFrame.getSrc().equals("")) {
NavNode node = state.getSelectedNode();
if (node != null && node.getType() == NavNode.TYPE_CASE) {
sourcePanelFrame.setSrc("/common/source.faces");
} else {
sourcePanelFrame.setSrc("/common/source-notfound.html");
}
update.markAttributeUpdate(sourcePanelFrame, "src");
}
}
...
}