无法从 SEAM 组件调用方法

发布于 2024-12-21 17:49:36 字数 5571 浏览 3 评论 0原文

我有一个 SEAM 2 应用程序,但我遇到了一个奇怪的情况。我正在使用 Eclipse Indigo 进行开发,我需要创建一个带有网格的页面,其中每行都有一个按钮,显示一个带有列表的弹出窗口,您可以使用链接选择列表中的一项,并显示所选值在行中。

所以我有这个组件:

@Name("paramContHome")
@Scope(ScopeType.CONVERSATION)
public class ParamContHome extends KubeDAO<ParametroSistema>{

    private static final long serialVersionUID = 1L;

    @In
    private LoginUser loginUser;

    @In(required=false,create=true)
    private CuentaContHome cuentaContHome;

    public void load(){
        try{
            setInstance(getEntityManager().find(ParametroSistema.class, prctId));
        }catch (Exception e) {
            clearInstance();
            setInstance(new ParametroSistema());
        }
    }

    public void selCuentaParam(ParametroSistema par) {
        setSelParam(par);
        cuentaContHome.getCuentasList();
    }

    public void setCuentaParam(CuentaContable cta) {
        selParam.setValorNum(cta.getId().floatValue());
        selParam.setSelObj(cta);
    }

    ...

    }

它包含我尝试从 xhtml 页面调用的方法。这是xhtml页面:

<?xml version="1.0" encoding="iso-8859-1" ?>
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
    xmlns:s="http://jboss.com/products/seam/taglib"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:a="http://richfaces.org/a4j"
    xmlns:rich="http://richfaces.org/rich"
    xmlns:p="http://primefaces.prime.com.tr/ui"
    template="/layout/templateKu.xhtml">
    <ui:define name="body">
        <rich:panel>
            <f:facet name="header">#{app.paramact_head}</f:facet>
            <rich:spacer height="20" />
            <h:form id="formA">
                <p:growl globalOnly="true" sticky="false" life="3000" />
                <p:focus />
                <a:queue name="q1" />

                <rich:dataTable var="res" value="#{paramContHome.resultList}"
                    rendered="#{not empty paramContHome.resultList}" rows="10"
                    align="center" rowClasses="tableInfo1 tableInfo2"
                    headerClass="tablaHeader" footerClass="tableScroll">
                    <f:facet name="header">#{app.paramact_list}</f:facet>

                    <rich:column filterBy="#{res.nombre}" filterEvent="onkeyup">
                        <f:facet name="header">#{app.paramact_nombre}</f:facet>
                        <h:outputText value="#{res.nombre}" />
                    </rich:column>
                    <rich:column>
                        <f:facet name="header">#{app.transferencia_valornum}</f:facet>
                        <h:inputText value="#{res.selObj.nombre}" size="20" >
                            <a:support event="onblur" ajaxSingle="true" eventsQueue="q1" reRender="_table"/>
                        </h:inputText>
                        <a:commandButton ajaxSingle="true"   
                            action="#{paramContHome.selCuentaParam(res)}" reRender="sCta" 
                            onclick="#{rich:component('selCta')}.show();"
                            styleClass="modifyBtn" value=" " style="width:30px;">
                        </a:commandButton>
                    </rich:column>
                    <f:facet name="footer">
                        <rich:datascroller id="ds1" renderIfSinglePage="true" />
                    </f:facet>
                </rich:dataTable>
            </h:form>
        </rich:panel>
        <rich:modalPanel id="selCta" width="400" moveable="false" autosized="true" top="50px" 
            onbeforeshow="activeModal.setActiveModalPanel('selCta');">
            <f:facet name="header">#{app.general_lov}</f:facet>
            <f:facet name="controls">
                <h:panelGroup>
                    <h:graphicImage value="/kubeImg/close.png" styleClass="closeBtn" 
                        onclick="#{rich:component('selCta')}.hide();" />
                </h:panelGroup>
            </f:facet>
            <s:div id="sCta"><ui:include  src="selCta.xhtml" /></s:div>
        </rich:modalPanel>
    </ui:define>
</ui:composition>

这是我想调用组件paramContHome的selCuentaParam方法的按钮:

<rich:column>
    <f:facet name="header">#{app.transferencia_valornum}</f:facet>
    <h:inputText value="#{res.selObj.nombre}" size="20" >
        <a:support event="onblur" ajaxSingle="true" eventsQueue="q1" reRender="_table"/>
    </h:inputText>
    <a:commandButton ajaxSingle="true"   
        action="#{paramContHome.selCuentaParam(res)}" reRender="sCta" 
        onclick="#{rich:component('selCta')}.show();"
        styleClass="modifyBtn" value=" " style="width:30px;">
    </a:commandButton>
</rich:column>

在这个方法中,我调用另一个组件cuentaContHome的方法:

@In(required=false,create=true)
private CuentaContHome cuentaContHome;
...
public void selCuentaParam(ParametroSistema par) {
setSelParam(par);
cuentaContHome.getCuentasList();
}

但是当我运行应用程序并进入页面时,我按按钮,它不会调用方法 selCuentaParam。我已经检查过这一点,因为我在其中放置了断点并放置了 System.out.println 并且没有调用它。您知道为什么会发生这种情况吗?与组件初始化有关吗?

问候。

i have a SEAM 2 application and i have a strange situation. I'm developing with Eclipse Indigo, and i need to create a page with a grid where each row has a button that display a popup window with a list and you can choose one item of the list with a link and the value selected is shown in the row.

So i have this component:

@Name("paramContHome")
@Scope(ScopeType.CONVERSATION)
public class ParamContHome extends KubeDAO<ParametroSistema>{

    private static final long serialVersionUID = 1L;

    @In
    private LoginUser loginUser;

    @In(required=false,create=true)
    private CuentaContHome cuentaContHome;

    public void load(){
        try{
            setInstance(getEntityManager().find(ParametroSistema.class, prctId));
        }catch (Exception e) {
            clearInstance();
            setInstance(new ParametroSistema());
        }
    }

    public void selCuentaParam(ParametroSistema par) {
        setSelParam(par);
        cuentaContHome.getCuentasList();
    }

    public void setCuentaParam(CuentaContable cta) {
        selParam.setValorNum(cta.getId().floatValue());
        selParam.setSelObj(cta);
    }

    ...

    }

That contains the methods that i'm trying to call from xhtml page. This is the xhtml page:

<?xml version="1.0" encoding="iso-8859-1" ?>
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
    xmlns:s="http://jboss.com/products/seam/taglib"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:a="http://richfaces.org/a4j"
    xmlns:rich="http://richfaces.org/rich"
    xmlns:p="http://primefaces.prime.com.tr/ui"
    template="/layout/templateKu.xhtml">
    <ui:define name="body">
        <rich:panel>
            <f:facet name="header">#{app.paramact_head}</f:facet>
            <rich:spacer height="20" />
            <h:form id="formA">
                <p:growl globalOnly="true" sticky="false" life="3000" />
                <p:focus />
                <a:queue name="q1" />

                <rich:dataTable var="res" value="#{paramContHome.resultList}"
                    rendered="#{not empty paramContHome.resultList}" rows="10"
                    align="center" rowClasses="tableInfo1 tableInfo2"
                    headerClass="tablaHeader" footerClass="tableScroll">
                    <f:facet name="header">#{app.paramact_list}</f:facet>

                    <rich:column filterBy="#{res.nombre}" filterEvent="onkeyup">
                        <f:facet name="header">#{app.paramact_nombre}</f:facet>
                        <h:outputText value="#{res.nombre}" />
                    </rich:column>
                    <rich:column>
                        <f:facet name="header">#{app.transferencia_valornum}</f:facet>
                        <h:inputText value="#{res.selObj.nombre}" size="20" >
                            <a:support event="onblur" ajaxSingle="true" eventsQueue="q1" reRender="_table"/>
                        </h:inputText>
                        <a:commandButton ajaxSingle="true"   
                            action="#{paramContHome.selCuentaParam(res)}" reRender="sCta" 
                            onclick="#{rich:component('selCta')}.show();"
                            styleClass="modifyBtn" value=" " style="width:30px;">
                        </a:commandButton>
                    </rich:column>
                    <f:facet name="footer">
                        <rich:datascroller id="ds1" renderIfSinglePage="true" />
                    </f:facet>
                </rich:dataTable>
            </h:form>
        </rich:panel>
        <rich:modalPanel id="selCta" width="400" moveable="false" autosized="true" top="50px" 
            onbeforeshow="activeModal.setActiveModalPanel('selCta');">
            <f:facet name="header">#{app.general_lov}</f:facet>
            <f:facet name="controls">
                <h:panelGroup>
                    <h:graphicImage value="/kubeImg/close.png" styleClass="closeBtn" 
                        onclick="#{rich:component('selCta')}.hide();" />
                </h:panelGroup>
            </f:facet>
            <s:div id="sCta"><ui:include  src="selCta.xhtml" /></s:div>
        </rich:modalPanel>
    </ui:define>
</ui:composition>

This is the button where i wanna call the method selCuentaParam of component paramContHome:

<rich:column>
    <f:facet name="header">#{app.transferencia_valornum}</f:facet>
    <h:inputText value="#{res.selObj.nombre}" size="20" >
        <a:support event="onblur" ajaxSingle="true" eventsQueue="q1" reRender="_table"/>
    </h:inputText>
    <a:commandButton ajaxSingle="true"   
        action="#{paramContHome.selCuentaParam(res)}" reRender="sCta" 
        onclick="#{rich:component('selCta')}.show();"
        styleClass="modifyBtn" value=" " style="width:30px;">
    </a:commandButton>
</rich:column>

Inside this method, i call a method from another component, cuentaContHome:

@In(required=false,create=true)
private CuentaContHome cuentaContHome;
...
public void selCuentaParam(ParametroSistema par) {
setSelParam(par);
cuentaContHome.getCuentasList();
}

But when i run the application and enter to the page, and i press the button, it doesn't calle the method selCuentaParam. I've checked this because i put breakpoints inside it and put System.out.println and doesn't invoke it. Do you know why this happens, is something related to component initialization?

Regards.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

薄凉少年不暖心 2024-12-28 17:49:36

好吧,我想我发现了问题。在我的屏幕中,我遵循某种模式:首先,我有一个 xhtml,其中显示数据库记录网格,并带有一个按钮,用于转到第二个 xhtml,其中有一个用于创建新记录的表单。该按钮开始对话,因此在具有表单(我称之为detail.xhtml)的xhtml 中,它开始对话或加入现有对话。所以,我用下面的方式修改了第一个xhtml(我称之为list.xhtml)的pages.xml:

<?xml version="1.0" encoding="UTF-8"?>
<page xmlns="http://jboss.com/products/seam/pages"
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jboss.com/products/seam/pages http://jboss.com/products/seam/pages-2.2.xsd">
 <action execute="#{paramContHome.getParametrosContables()}" on-postback="false"/>

       <begin-conversation propagation="begin" join="true" />

</page>

我首先使用了 ,但它给了我这个从长时间运行的对话中调用异常 begin(),尝试 join=true 所以我将其添加到开始对话中并且它有效!

Well, i found the problem, i think. In my screens i follow a certain pattern: First i have a xhtml where i show a grid of database records with a button to go to a second xhtml wich has a form to create a new record. This button begins a conversation, so in the xhtml that has a form (i call it detail.xhtml) it begins the conversation or joins to existing one. So, i modified the pages.xml of the first xhtml (i call it list.xhtml) in the next way:

<?xml version="1.0" encoding="UTF-8"?>
<page xmlns="http://jboss.com/products/seam/pages"
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jboss.com/products/seam/pages http://jboss.com/products/seam/pages-2.2.xsd">
 <action execute="#{paramContHome.getParametrosContables()}" on-postback="false"/>

       <begin-conversation propagation="begin" join="true" />

</page>

I used first just <begin-conversation /> and but it gives me this exception begin() called from long-running conversation, try join=true so i added this to begin-conversation and it works!!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文