1

so i have a

A.xhtml

<p:tabView id="headOfAccountsId_tabview">
<p:tab title="Main Head Of Accounts" id="mainHeadOfAccountsId_tab">
 // completely finished with codes 
 // here i have done some inputtext fields with jsf validation , 
 // and submit button to call action on ajax
 // and p:datatable to view only records and user can edit and delete record on ajax
</p:tab>
<p:tab title="Sub Head Of Accounts" id="subHeadOfAccountsId_tab">
 // just have open and closing tags of p:tab i meant i will do code later here 
</p:tab>
</p:tabView>

and i have an other xhmt file for different purpose on that i am using

B.xhtml

 // all the input fields outside the <p:tabView >
 // here i have done some inputtext fields with jsf validation , 
 // and submit button to call action on ajax
<p:tabView >
<p:tab>
 //p:datatable to view only records
</p:tab>
<p:tab>
//p:datatable to view only records
</p:tab>
</p:tabView>

my question is that in both files (A and B) i haved used

<p:ajax event="tabChange" />

but in file A.xhtml when i changed the tab listener does not call method(action method of java class) without

  immediate="true"

and in file B.xhtml when i am changing tabs method is calling without

  immediate="true"

can any one makes me understand whats happening ? or why/where we use 'immediate' attribute ? should i post my whole code ?

4

2 回答 2

2

对于文件 A.xhtml,它们将是一个验证错误,因此它不会调用 InvokeApllication 阶段。

但在 B.xhtml 中,它们不会出现验证错误,因此它调用 InvokeApplication 阶段并调用您的托管 bean 方法。

放入 <p:message autoUpdate="true" />您的 A.xhtml,您可能会收到错误消息

其中 immediate="true" 是跳过验证阶段..

于 2013-10-12T08:37:12.687 回答
2

immediate="true"导致在任何验证/转换之前在“应用请求值”阶段调用操作。该标记默认为 false,这使 JSF 经历标准生命周期并在“调用应用程序”阶段调用操作。

我猜(很难从您的存根示例中得到它)您有验证或转换错误。在发生错误事件时,JSF 会跳过剩余的生命周期阶段,因此tabChange不会调用该事件。

<h:messages />您应该尝试通过在页面顶部创建标签或检查堆栈跟踪(如果已记录)来调试它。

欲了解更多信息,请参阅:

http://www.javacodegeeks.com/2012/01/jsf-and-immediate-attribute-command.html

http://docs.oracle.com/javaee/6/tutorial/doc/bnaqq.html

http://balusc.blogspot.hu/2006/09/debug-jsf-lifecycle.html#AddImmediateTrueToUIInputOnly

于 2013-10-12T06:40:54.353 回答