0

テキスト領域にキューを配置しようとしましたが、うまくいきません。以下に、関連するコードのセクションをリストします。

<h:form>
    <a4j:queue requestDelay="1000" ignoreDupResponses="true"/>
    <table>
        <tr>
            <td>
                <h:outputText value="Notes:"/>
            </td>
        </tr>
        <tr>
            <td>
                <h:inputTextarea value="#{MyActionBean.notes}">
                    <a4j:ajax event="keyup" listener="#{MyActionBean.updateNotes}"/>
                </h:inputTextarea>

メモは期待どおりに更新されますが、リクエスト間に遅延はありません。私のコードにバグがありますか? どんな助けでも大歓迎です。

編集:念のため、次のコードも試しましたが、どちらも機能しませんでした。

<h:panelGrid columns="1" width="100%">
    <h:outputText value="Notes:"/>
    <h:inputTextarea value="#{MyActionBean.notes}">
        <a4j:ajax event="keyup" listener="#{MyActionBean.updateNotes}">
            <a4j:attachQueue id="notesQueue" requestDelay="1000"/>
        </a4j:ajax>
    </h:inputTextArea>
</h:panelGrid>

参考までに、テクノロジ バージョン: JBoss AS 7、Seam 2.3.0、Richfaces 4.2.2、JSF 2.1

4

1 に答える 1

0

あなたの場合、a4j:attachQueue内部にネストする必要がありますa4j。以下のコードを実行してみると、15 秒後にコンソールに出力が表示されることがわかります。

<h:head>
    <title>Facelet Title</title>
</h:head>
<h:body>
    <h:form>
        <a4j:queue name='Y' requestDelay="3000" ignoreDupResponses="true"/>
        <h:panelGrid columns="1" width="100%">
            <h:outputText value="Notes:"/>
            <h:inputTextarea value="#{MyActionBean.notes}">
                <a4j:ajax event="keyup" listener="#{MyActionBean.updateNotes}">
                    <a4j:attachQueue requestDelay="3000"/> 
                </a4j:ajax>             
            </h:inputTextarea>
            <a4j:status>
                <f:facet name="start">
                    Please wait
                </f:facet>
            </a4j:status>
        </h:panelGrid>
    </h:form>
</h:body>

詳細情報が必要な場合は、このリンクを使用できます

アップデート

私はあなたが送ったコードを最小限に抑えましたが、JBoss でまだ動作していると言って申し訳ありません。問題が別の場所にある可能性があります (たとえば、「お待ちください」が表示されないと言われたため、何らかの理由で ajax が失敗している可能性があります)。ただし、JBoss の会話スコープに慣れていないので、変更しましたjavax.enterprise.context.SessionScoped(ただし、requestscoped のときにまだ機能していたので、それは問題ではないと思います)。別のプロジェクトとして自分でテストできるように、すべてのコードを含めます。また、キューを使用しているため、ログの場所を から に変更しupdateNotessetReport、キャラクターが実際にキューに入れられていることを確実に確認できるようにしました。「これはテストです」と入力すると、

AssessmentCheckListAction.java

import java.io.Serializable;
import javax.faces.context.FacesContext;
import javax.inject.Named; 
import javax.enterprise.context.SessionScoped; 

@Named(value="AssessmentChecklistAction")
@SessionScoped
public class AssessmentCheckListAction implements Serializable {

    private static final long serialVersionUID = -4970638494437413924L;
    private String report;

    public AssessmentCheckListAction() {
    }

    public void updateNotes() {
        //FacesContext.getCurrentInstance().getExternalContext().log(report);
        //Logging the setter to make sure everything was queued
    }

    public String getReport() {
        return report;
    }

    public void setReport(String report) {
        FacesContext.getCurrentInstance().getExternalContext().log(report);
        this.report = report;
        //left blank
    }

index.xhtml

<?xml version='1.0' encoding='UTF-8' ?>
<!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:h="http://java.sun.com/jsf/html">
    <h:head>
        <title>Facelet Title</title>
    </h:head>
    <h:body>
        <ui:composition xmlns="http://www.w3.org/1999/xhtml"
                        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:a4j="http://richfaces.org/a4j"
                        template="template.xhtml">
            <ui:define name="content">
                <h:form>
                    <a4j:queue requestDelay="3000" ignoreDupResponses="true"/>
                    <h:panelGrid columns="1" width="100%">
                        <h:outputText value="Notes:"/>
                        <h:inputTextarea value="#{AssessmentChecklistAction.report}">
                            <a4j:ajax event="keyup" listener="#{AssessmentChecklistAction.updateNotes}">
                                <a4j:attachQueue requestDelay="3000"/> 
                            </a4j:ajax>             
                        </h:inputTextarea>
                        <a4j:status>
                            <f:facet name="start">
                                Please wait
                            </f:facet>
                        </a4j:status>
                    </h:panelGrid>
                </h:form>
            </ui:define>
        </ui:composition>
    </h:body>
</html>

template.xhtml

<?xml version='1.0' encoding='UTF-8' ?>
<!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:h="http://java.sun.com/jsf/html"
      xmlns:ui="http://java.sun.com/jsf/facelets">
    <h:head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
        <meta http-equiv="Cache-Control" content="no-store"/>
        <meta http-equiv="Pragma" content="no-cache"/>
        <meta http-equiv="Expires" content="0"/>              
    </h:head>

    <h:body>
        <ui:insert name="content"/>
    </h:body>
</html>
于 2013-07-02T20:35:11.567 に答える