简体   繁体   English

如何将响应从Backing Bean转发到JSF页面?

[英]How to forward a response to a JSF page from Backing Bean?

Im currently working in a JSF project and stuck with an issue. 我目前在JSF项目中工作,并且遇到了问题。 I have a requirement like, 我有一个要求,

  1. I have a button. 我有一个按钮。 Clicking on the button should trigger a dojo dialog box where it will be having a "OK" and "Cancel" button along with an info message. 单击该按钮将触发一个dojo对话框,其中将带有“确定”和“取消”按钮以及一条信息消息。 Clicking on the cancel button will close the popup. 单击取消按钮将关闭弹出窗口。

  2. Clicking on "OK" button will submit the form in javascript by calling document.formname.submit(). 单击“确定”按钮将通过调用document.formname.submit()来提交javascript表单。

The issue is the on submitting, i need to take the user to another page with the response. 问题是提交时,我需要将用户带到另一个带有响应的页面。 I mean forward not Redirect. 我的意思是转发而不是重定向。 If i use h:commandButton with action attribute, then the pop up appears and it submits the form without waiting for user action in the popup.. 如果我将h:commandButton与action属性一起使用,则会出现弹出窗口,并且它将提交表单,而无需等待弹出窗口中的用户操作。

I want the fisrt button click should trigger javascript function and that "OK" should submit the form and forwards the response to another page. 我希望单击fisrt按钮可以触发javascript函数,并且“确定”应该提交表单并将响应转发到另一个页面。

Please suggest me how can i do this with my xhtml,javascript,backing bean and faces-config. 请建议我如何使用我的xhtml,javascript,backing bean和faces-config来做到这一点。 If needed i will post some sample code also. 如果需要,我还将发布一些示例代码。

As of now i have like this, 到目前为止,我已经这样

xhtml 的xhtml

<h:commandButton id="viewBtn" type="button" value="submit" onclick="submidt()"/>

js: js:

function submidt() {
                var h = new dijit.Dialog({
                    title: "Hello"
                });
                var content = "<input type='button' onclick='document.searchSecurityForm.submit();' value='OK' /><input type='button' onclick='this.hide();' value='Cancel' />";
                h.attr("content",content);
                h.show();
            }

faces-config: faces-config:

    <navigation-rule>
    <from-view-id>/viewpage.xhtml</from-view-id>
    <navigation-case>
        <to-view-id>/editpage.xhtml</to-view-id>
    </navigation-case>
</navigation-rule>

so these makes me to stay in the same page(View Page) with the response. 因此,这些使我能够与响应保持在同一页面(“查看页面”)。 I want to make the user to take to edit page. 我想让用户来编辑页面。

Thanks in advance. 提前致谢。 goG goG

If i use h:commandButton with action attribute, then the pop up appears and it submits the form without waiting for user action in the popup.. 如果我将h:commandButton与action属性一起使用,则会出现弹出窗口,并且它将提交表单,而无需等待弹出窗口中的用户操作。

return false at the end of your javascript onclick method. 在javascript onclick方法的末尾返回false。

function submidt() {
    var h = new dijit.Dialog({
        title: "Hello"
    });

    var content = "<input type='button' onclick='document.searchSecurityForm.submit();' value='OK' /><input type='button' onclick='this.hide();' value='Cancel' />";
    h.attr("content",content);
    h.show();
    return false;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 JSF 页面到支持 bean 荒谬的延迟 - JSF Page to backing bean absurd latency 从JavaScript + JSF调用Backing bean方法 - Invoke Backing bean method from JavaScript + JSF 如何仅在加载页面时使用 javascript 调用 JSF 支持 bean 方法 - How to call JSF backing bean method using javascript only when The page is loaded 如何从自定义JSF组件中的支持bean加载jquery json数据? - How to load with jquery json data from a backing bean in a custom JSF component? 支持bean方法返回时如何在JSF中进行检测 - How to detect in JSF when the backing bean method returns 如何将JavaScript值传递给JSF EL和支持bean? - How to pass JavaScript values to JSF EL and backing bean? JSF 1.1-无需页面刷新即可备份bean的调用操作方法(通过ajax / javascript) - JSF 1.1-Calling action method of backing bean without page refresh(through ajax/javascript) 为什么JSF支持bean函数不能在Firefox中从JavaScript调用而在IE和Chrome中可以正常工作? - Why JSF backing bean function not call from JavaScript in Firefox but working fine in IE and Chrome? 使用javascript var或其他标记值从JSF支持bean调用函数 - Call function from JSF backing bean with javascript var or other tag value 在JSF中如何在使用backing bean方法获取值后调用java脚本 - In JSF how to invoke java script after getting a value using backing bean method
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM