【问题标题】:I called a function from two pages .One page works and other page does not works properly我从两个页面调用了一个函数。一个页面可以正常工作,而另一个页面不能正常工作
【发布时间】:2012-07-24 06:32:57
【问题描述】:

在索引中包含树页面(列表、视图、编辑)并使用相同的命令拖曳页面(列表和视图)。当我 List.xhtml 页面的查看或编辑按钮单击并打开它时;但是 View.xhtml 页面的 Edit 按钮点击然后显示在流动的按摩中:

Unable to find matching navigation case with from-view-id '/index.xhtml' for action '#{instituteController.viewEdit}' with outcome 'null'

我想要查看页面的编辑按钮单击以编辑页面打开到索引页面。 List.xhtml 代码:

<h:commandButton action="#{instituteController.prepareView}" value="#{bundle.ListInstituteViewLink}">
   <f:ajax execute="@form" render="@form"/>
</h:commandButton>

<h:commandButton action="#{instituteController.prepareEdit}" value="#{bundle.ListInstituteEditLink}">
    <f:ajax execute="@form" render="@form"/>
</h:commandButton>

查看.xhtml代码

 <h:commandButton action="#{instituteController.viewEdit}" value="#{bundle.ListInstituteEditLink}">
 <f:ajax execute="@form" render="@form"/>
</h:commandButton>

instituteController.java 代码:

   public String prepareEdit() {
    current = (Institute) getItems().getRowData();
    selectedItemIndex = pagination.getPageFirstItem() + getItems().getRowIndex();
    return "index";
}
 public String viewEdit() {

          return "null";
}

如果我返回 "index" ;这个命令不起作用。再次显示此代码:

          public String viewEdit() {

          return "index";
          }

【问题讨论】:

    标签: jsf-2 managed-bean


    【解决方案1】:

    你的错误在这里:

    public String viewEdit() {
        // ...
        return "null";
    }
    

    您正在返回一个值为"null"String 实例。这与文字 null 不同。

    相应地修复它:

    public String viewEdit() {
        // ...
        return null;
    }
    

    或者什么都不返回:

    public void viewEdit() {
        // ...
    }
    

    【讨论】:

    • 感谢您的回答。但是当我刷新或重新加载页面时,此页面会显示。我想在不重新加载或刷新的情况下显示此页面。
    【解决方案2】:

    因为您返回“null”,所以写在您的异常中。如果您想留在同一页面或您想去的页面的名称,则返回空字符串。

    【讨论】:

      猜你喜欢
      • 2011-04-12
      • 2021-01-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-01-27
      • 1970-01-01
      • 2014-05-04
      相关资源
      最近更新 更多