Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/jsf/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在jsf中有很多页面_Jsf - Fatal编程技术网

在jsf中有很多页面

在jsf中有很多页面,jsf,Jsf,我是jsf新手,并做了以下工作:例如,我要求用户填写表单,然后提交表单。提交后,我想显示提交是否成功。为此,我创建了另一个html页面,提交后,如果成功,我将页面重定向到这个新的成功html页面。所以,我的项目中有很多网页。我的问题是,这是件坏事吗?除了创建许多“成功”的页面之外,我还可以尝试其他解决方案吗?我是这样做的: <h:form> <h:panelGrid columns="2"> <h:outputText val

我是jsf新手,并做了以下工作:例如,我要求用户填写表单,然后提交表单。提交后,我想显示提交是否成功。为此,我创建了另一个html页面,提交后,如果成功,我将页面重定向到这个新的成功html页面。所以,我的项目中有很多网页。我的问题是,这是件坏事吗?除了创建许多“成功”的页面之外,我还可以尝试其他解决方案吗?我是这样做的:

<h:form>
        <h:panelGrid columns="2">
            <h:outputText value="Select one:"></h:outputText>
            <rich:select  defaultLabel="Select..."  value="#{account.accountCurrency}" >
                <f:selectItem itemValue="a" itemLabel="a" />
                <f:selectItem itemValue="b" itemLabel="b" />
                <f:selectItem itemValue="c" itemLabel="c" />
            </rich:select>

            <h:commandButton value="Submit" action="#{selection.approve}" ></h:commandButton>
        </h:panelGrid>           
    </h:form>

谢谢您,您可以使用复合组件和模板来帮助减少所需的代码量。

使用messages组件来显示回发的消息

<h:commandButton value="Submit" actionListener="#{somebean.someMethod}">
    <f:ajax  render="msg"/>
</h:commandButton>
<h:messages id="msg"/>

这可能会有所帮助——顺便说一句,我的假设是,您的结果页面包含输入的数据。只需重新显示带有消息的同一页面?@BalusC我怎么能做到这一点?提交后,我重定向到同一页面,但页面内容如何更改?OP使用的是非ajax行为的
h:commandButton
。在这种情况下,下一页应该有可用的消息来呈现它,但由于请求不同,消息将丢失。他可能需要使用它。@XtremeBiker OP要求提供一种替代多页的方法。这是一种通过在同一页面中显示消息来创建多个页面的替代方法(因此,ajax)。所以在这种情况下,“不会再有下一页了”。基本上,我们以不同的方式阅读这个问题。我知道他谈到了不同的文件(基本上是因为他谈到了在他的项目中创建页面),就我所见,你谈到了多个URL。通过我的解释,您可以轻松解决只有一个成功页面(带有url或导航结果)并使用flash scope传递成功消息的问题。
<h:commandButton value="Submit" actionListener="#{somebean.someMethod}">
    <f:ajax  render="msg"/>
</h:commandButton>
<h:messages id="msg"/>
String msg = "Successfully submitted!";
FacesMessage fm = new FacesMessage(FacesMessage.SEVERITY_INFO, msg, null);
FacesContext.getCurrentInstance().addMessage(null, fm);