JBoss Seam:在ScopeType.PAGE中我得到:java.lang.IllegalStateException:没有活动的对话上下文
我有一个页面范围的组件,它有一个包含数据的实例变量列表,显示在datatable中。此数据表具有分页、排序和筛选功能 第一次进入页面时,我在我的URL中附加了这个:?conversationId=97。页面工作正常,当我更改datatable页面时,现在不会创建任何组件 一两分钟后,在极其随机的时间,我得到一个例外,说没有上下文。我没有在我的代码或导航文件中使用@Create 因此,我有两个问题:JBoss Seam:在ScopeType.PAGE中我得到:java.lang.IllegalStateException:没有活动的对话上下文,java,jsf,seam,Java,Jsf,Seam,我有一个页面范围的组件,它有一个包含数据的实例变量列表,显示在datatable中。此数据表具有分页、排序和筛选功能 第一次进入页面时,我在我的URL中附加了这个:?conversationId=97。页面工作正常,当我更改datatable页面时,现在不会创建任何组件 一两分钟后,在极其随机的时间,我得到一个例外,说没有上下文。我没有在我的代码或导航文件中使用@Create 因此,我有两个问题: 为什么我的URL中有这个后缀?为什么要开始对话 为什么会有例外?该组件的作用域为第页。如果我收到
- 为什么我的URL中有这个后缀?为什么要开始对话
- 为什么会有例外?该组件的作用域为第页。如果我收到一个异常,它不应该与对话相关。对吗?或者该对话是指临时对话的例外情况
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:a4j="http://richfaces.org/a4j"
xmlns:rich="http://richfaces.org/rich">
<body>
<ui:composition template="/WEB-INF/facelets/templates/template.xhtml">
<ui:define name="content">
<!-- This method returns focus on the filter -->
<script type="text/javascript">
function submitByEnter(event){
if (event.keyCode == 13) {
if (event.preventDefault) {
// Firefox
event.preventDefault();
} else {
// IE
event.returnValue = false;
}
document.getElementById("refreshButton").click();
}
}
</script>
<h:form prependId="false">
<h:commandButton action="Back" value="Back to home page" />
<br />
<p><h:outputText
value="Applicants and Products (experimentation page)"
class="page_title" /></p>
<h:commandButton
action="#{applicantProductListBean.showCreateApplicant}"
value="Create Applicant" id="createApplicantButton">
</h:commandButton>
<a4j:commandButton value="Refresh" id="refreshButton"
action="#{applicantProductListBean.refreshData}"
image="/images/icons/refresh48x48.gif"
reRender="compositeTable, compositeScroller">
<!-- <f:setPropertyActionListener-->
<!-- target="# {pageScrollerBean.applicantProductListPage}" value="1" />-->
</a4j:commandButton>
<rich:toolTip for="createApplicantButton" value="Create Applicant" />
<rich:dataTable styleClass="composite2DataTable" id="compositeTable"
rows="1" columnClasses="col"
value="#{applicantProductListBean.dataModel}" var="pageAppList">
<f:facet name="header">
<rich:columnGroup>
<rich:column colspan="3">
<h:outputText styleClass="headerText" value="Applicants" />
</rich:column>
<rich:column colspan="3">
<h:outputText styleClass="headerText" value="Products" />
</rich:column>
<rich:column breakBefore="true">
<h:outputText styleClass="headerText" value="Applicant Name" />
<a4j:commandButton id="sortingApplicantNameButton"
action="#{applicantProductListBean.toggleSorting('applicantName')}"
image="/images/icons/sorting/#{sortingFilteringBean.applicantProductListSorting.sortingValues['applicantName']}.gif"
reRender="sortingApplicantNameButton, sortingApplicantEmailButton, compositeTable, compositeScroller">
<!-- <f:setPropertyActionListener-->
<!-- target="#{pageScrollerBean.applicantProductListPage}" value="1" />-->
</a4j:commandButton>
<br />
<h:inputText
value="#{sortingFilteringBean.applicantProductListFiltering.filteringValues['applicantName']}"
id="applicantNameFilterValue"
onkeypress="return submitByEnter(event)">
</h:inputText>
</rich:column>
<rich:column>
<h:outputText styleClass="headerText" value="Applicant Email" />
<a4j:commandButton id="sortingApplicantEmailButton"
action="#{applicantProductListBean.toggleSorting('applicantEmail')}"
image="/images/icons/sorting/#{sortingFilteringBean.applicantProductListSorting.sortingValues['applicantEmail']}.gif"
reRender="sortingApplicantNameButton, sortingApplicantEmailButton, compositeTable, compositeScroller">
<!-- <f:setPropertyActionListener-->
<!-- target="#{pageScrollerBean.applicantProductListPage}" value="1" />-->
</a4j:commandButton>
<br />
<h:inputText
value="#{sortingFilteringBean.applicantProductListFiltering.filteringValues['applicantEmail']}"
id="applicantEmailFilterValue"
onkeypress="return submitByEnter(event)">
</h:inputText>
</rich:column>
<rich:column>
<h:outputText styleClass="headerText" value="Applicant Actions" />
</rich:column>
<rich:column>
<h:outputText styleClass="headerText" value="Product Name" />
<a4j:commandButton id="sortingProductNameButton"
action="#{applicantProductListBean.toggleSorting('productName')}"
immediate="true"
image="/images/icons/sorting/#{sortingFilteringBean.applicantProductListSorting.sortingValues['productName']}.gif"
reRender="sortingProductNameButton, compositeTable, compositeScroller">
</a4j:commandButton>
<br />
<h:inputText
value="#{sortingFilteringBean.applicantProductListFiltering.filteringValues['productName']}"
id="productNameFilterValue"
onkeypress="return submitByEnter(event)">
</h:inputText>
</rich:column>
<rich:column>
<h:outputText styleClass="headerText" value="Product Email" />
<br />
<h:inputText
value="#{sortingFilteringBean.applicantProductListFiltering.filteringValues['productEmail']}"
id="productEmailFilterValue"
onkeypress="return submitByEnter(event)">
</h:inputText>
</rich:column>
<rich:column>
<h:outputText styleClass="headerText" value="Product Actions" />
</rich:column>
</rich:columnGroup>
</f:facet>
<rich:subTable rowClasses="odd_applicant_row, even_applicant_row"
value="#{pageAppList}" var="app">
<rich:column
styleClass=" internal_cell
composite2TextContainingColumn"
valign="top">
<h:outputText value="#{app.name}" />
</rich:column>
<rich:column
styleClass="internal_cell composite2TextContainingColumn"
valign="top">
<h:outputText value="#{app.receiptEmail}" />
</rich:column>
<rich:column valign="top" styleClass="buttonsColumn">
<h:commandButton
action="#{applicantProductListBean.showUpdateApplicant(app)}"
image="/images/icons/edit.jpg">
</h:commandButton>
<!-- <rich:toolTip for="editApplicantButton" value="Edit Applicant" />-->
<h:commandButton
action="#{applicantProductListBean.showDeleteApplicant(app)}"
image="/images/icons/delete.png">
</h:commandButton>
<!-- <rich:toolTip for="deleteApplicantButton" value="Delete Applicant" />-->
</rich:column>
<rich:column colspan="3">
<table class="productsTableTable">
<tbody>
<tr>
<td class="createProductButtonTableCell"><h:commandButton
action="#{applicantProductListBean.showCreateProduct(app)}"
value="Create Product">
</h:commandButton>
<!-- <rich:toolTip for="createProductButton" value="Create Product" />-->
</td>
</tr>
<tr>
<td><rich:dataTable value="#{app.products}" var="prod"
rowClasses="odd_product_row, even_product_row">
<rich:column
styleClass="internal_cell composite2TextContainingColumn">
<h:outputText value="#{prod.inventedName}" />
</rich:column>
<rich:column
styleClass="internal_cell composite2TextContainingColumn">
<h:outputText value="#{prod.receiptEmail}" />
</rich:column>
<rich:column styleClass="buttonsColumn">
<h:commandButton
action="#{applicantProductListBean.showUpdateProduct(prod)}"
image="/images/icons/edit.jpg">
</h:commandButton>
<!-- <rich:toolTip for="editProductButton" value="Edit Product" />-->
<h:commandButton
action="#{applicantProductListBean.showDeleteProduct(prod)}"
image="/images/icons/delete.png">
<f:setPropertyActionListener target="#{productBean.product}"
value="#{prod}" />
</h:commandButton>
<!-- <rich:toolTip for="deleteProductButton" value="Delete Product" />-->
</rich:column>
</rich:dataTable></td>
</tr>
</tbody>
</table>
</rich:column>
</rich:subTable>
<f:facet name="footer">
<h:panelGrid columns="1" styleClass="applicantProductListFooter">
<h:outputText value="#{msgs.no_results}" rendered="#{(empty applicantProductListBean.dataModel) || (applicantProductListBean.dataModel.rowCount==0)}"/>
<rich:datascroller align="center" for="compositeTable"
page="#{pageScrollerBean.applicantProductListPage}"
id="compositeScroller" reRender="compositeTable"
renderIfSinglePage="false" fastControls="hide">
<f:facet name="first">
<h:outputText value="#{msgs.first}" styleClass="scrollerCell" />
</f:facet>
<f:facet name="first_disabled">
<h:outputText value="#{msgs.first}" styleClass="scrollerCell" />
</f:facet>
<f:facet name="last">
<h:outputText value="#{msgs.last}" styleClass="scrollerCell" />
</f:facet>
<f:facet name="last_disabled">
<h:outputText value="#{msgs.last}" styleClass="scrollerCell" />
</f:facet>
<f:facet name="next">
<h:outputText value="#{msgs.next}" styleClass="scrollerCell" />
</f:facet>
<f:facet name="next_disabled">
<h:outputText value="#{msgs.next}" styleClass="scrollerCell" />
</f:facet>
<f:facet name="previous">
<h:outputText value="#{msgs.previous}" styleClass="scrollerCell" />
</f:facet>
<f:facet name="previous_disabled">
<h:outputText value="#{msgs.previous}" styleClass="scrollerCell" />
</f:facet>
</rich:datascroller>
</h:panelGrid>
</f:facet>
</rich:dataTable>
</h:form>
</ui:define>
函数提交者中心(事件){
如果(event.keyCode==13){
if(event.preventDefault){
//火狐
event.preventDefault();
}否则{
//即
event.returnValue=false;
}
document.getElementById(“刷新按钮”)。单击();
}
}
尝试进行组件范围的对话,而不是页面。听起来您想要做的事情比页面范围更大,页面范围只包含单个请求的上下文
我不知道你为什么把conversationId参数附加到你的url。然而,seam中的所有通信都发生在会话内部。如果其页面范围已确定,则该对话为临时对话。要将对话升级为长时间运行的对话,您需要开始注释或在pages.xml中开始对话
我认为seamBooking示例应用程序有一些示例代码,应该与您尝试执行的操作类似。好吧,让我们看看
第一次进入页面时,我在我的URL中追加了这个:?conversationId=97
嗯。正如Seam在行动手册中所说
默认情况下,Seam创建一个临时会话来服务当前请求。在JSF生命周期的恢复视图阶段之后,立即初始化一个临时会话,并在渲染响应阶段之后销毁
及
一两分钟后,在极其随机的时间,我得到一个例外,说没有上下文
每个对话都可以有自己的超时时间,默认为全局超时设置
/WEB-INF/components.xml
<core:manager conversation-timeout="1000000"/>
如果您看到true,那么您已经开始了一段长时间的对话。你甚至可以看到你的页面里面
#{conversation.longRunning}
我希望它能对您有所帮助。@Markos Fragkakis您能展示一下Seam组件和页面吗?耳朵还是战争?@Arthur Ronald F D Garcia我添加了密码。请再看一看。添加您的超类的代码(至少是相关部分)bean@MarkosFragkakis你最好提供我要求的相关代码:)@Bozho基于StackTrace,我认为这与Ajax4j有关。看一看谢谢你的回答(+1)。我还认为conversationId表示启动了一个长对话,尽管我不明白为什么。由于我还没有成功地显示调试页面,所以我在应用程序中包含了workspaces switcher,它不显示任何对话。但是,我也会尝试一下这个系统,看看它会显示什么。我使用Seam-JSF(a4j&Co.)的经验和这些错误是==花更多的时间来了解到底发生了什么,而不是修复我自己代码中的错误。我认为所有这些注释、xml和jsf组件只是隐藏和外部化了太多。。。很高兴我不再需要使用这些工具了。@fraido这个bug似乎与Weblogic server有关。但是学习基于服务器端的组件模型(如JSF、Vaadin和Wicket)的关键是理解其核心概念,以便充分利用它并避免很多头痛。因此,我认为基于服务器端的组件模型可以在web开发中发挥良好的作用。
/WEB-INF/components.xml
<core:manager conversation-timeout="1000000"/>
<page view-id="/app.xhtml" timeout="1000000"/>
/WEB-INF/web.xml
<!--specified in minutes-->
<session-config>
<session-timeout>30</session-timeout>
</session-config>
org.jboss.seam.core.Conversation conversation = (Conversation) Component.getInstance("conversation");
System.out.println(conversation.isLongRunning());
#{conversation.longRunning}