ITeye博客

jsf中怎样动态改变include的src地址

fourfire · 2007-05-16 15:53 · 企业架构 · Markdown

我想根据一个bean里的url,动态改变include中的src,试了几次都不行。

java 代码

 

  1. <body style="margin:0;" bgcolor="#f4f4ea">
  2. <f:view>
  3. <h:form id="form">
  4. <div >
  5. <e:include id="moduleTree" src="system/module_tree.jsp"/>
  6. </div>
  7. <div >
  8. <e:include id="mainPane" src="#{controlBean.mainPanePath}"/>
  9. </div>
  10. </h:form>
  11. </f:view>

java 代码

 

  1. public class ControlBean {
  2. private String mainPanePath="org_manager/context.jsp";
  3. /**
  4. * @return the mainPanePath
  5. */
  6. public String getMainPanePath() {
  7. return mainPanePath;
  8. }
  9. /**
  10. * @param mainPanePath the mainPanePath to set
  11. */
  12. public void setMainPanePath(String mainPanePath) {
  13. this.mainPanePath = mainPanePath;
  14. }
  15. public void setPath(ActionEvent event) {
  16. Module cell = ((Module) ((Tree) event.getSource()).getSelection());
  17. if (cell.getUrl() != null && cell.getUrl().trim().length() > 0) {
  18. this.setMainPanePath(cell.getUrl());
  19. }
  20. }
  21. }

tree

java 代码

 

  1. <e:tree id="tree-basic" model="#{moduleTreeModelBean.treeModel}"
  2. rootExpanded="false"
  3. onselection="#{controlBean.setPath}"
  4. cellStyle="normalTreeCell"
  5. hoverStyle="blueTreeCell"
  6. selectedStyle="whiteTreeCell" preloadDepth="1">
  7. <e:treecell value="#{NODE.name}"
  8. styleClass="treeCellBold"
  9. icon="#{NODE.leaf?'/images/draft.jpg':'/images/trash.jpg'}"/>
  10. </e:tree>

树上点击链接,改变另一个include的url

评论(2)

  1. #2 楼 · fourfire · 2007-05-17 09:01

    是个ecruiser的问题,需要把tree标记的ajax=false

  2. #1 楼 · fourfire · 2007-05-16 16:07

    后台都看到加载页面了,但是网页上没有变化

评论功能维护中,当前仅展示历史评论。