0

1.1、IceFaces 3.0.1、および JSF 2.1 を使用しており、ace:fileentry を操作しようとしていました。なぜリスナーが呼び出されないのか理解できません! IDE でも、「pruebaBean.sampleListener は不明なプロパティです」という警告が表示されます。これが私がやっていることの短い例です。送信ボタンをクリックしても何も起こりません。誰かが私を助けることができますか?? 何かのバグかも?

プルエバ.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:ice="http://www.icesoft.com/icefaces/component"
       xmlns:ace="http://www.icefaces.org/icefaces/components">
 
 <h:head>
 </h:head>
 <h:body>
     <ice:form id="usuarioForm">
         <ice:panelGrid columns="2">
             <ace:fileEntry id="fileEntryImage" absolutePath="c:\iTablero\imagenes"
                             useSessionSubdir="false" useOriginalFilename="false"
                             fileEntryListener="#{pruebaBean.sampleListener}"/>
             <ice:commandButton type="submit" value="Subir archivo"/>
         </ice:panelGrid>
         <ice:messages/>
     </ice:form>
 </h:body>

PruebaBean.java:

 package com.itablero.backingbeans;

 import java.io.Serializable;
 import javax.annotation.ManagedBean;
 import javax.faces.bean.RequestScoped;
 import org.icefaces.ace.component.fileentry.FileEntry;
 import org.icefaces.ace.component.fileentry.FileEntryEvent;
 import org.springframework.stereotype.Controller;

 @ManagedBean
 @Controller
 @RequestScoped
 public class PruebaBean implements Serializable {
 
     public void sampleListener (FileEntryEvent e) {
         System.out.println("it work!");
         FileEntry fe = (FileEntry) e.getComponent();
         //some others operations
     }
 }

更新 1

@fischermatte のおかげで、h:commandButton を ice:commandButton に置き換えることが問題であることがわかりました。しかし、これを元の完全な形に適用するとうまくいきませんでした。fileEntryListener メソッドが呼び出されることはありません。誰かがここでエラーを見ることができますか? 論理的には、前の例と以下のコードは同じ web.xml、faces-config.xml などを持っています。ファイルを送信するためのボタンは h:commandButton であり、完全なフォーム用の ice:commandButton があることに注意してください。私はすでにこれを h:cb で変更しようとしました。元のフォーム (ポップアップ/モーダル ウィンドウに表示) と Bean は次のとおりです。

usuariosList.xhtml

                <ice:panelPopup rendered="#{usuariosBean.showPopup}"
                            visible="#{usuariosBean.showPopup}"
                            modal="true"
                            autoCentre="true">

                <f:facet name="header">
                    <h:panelGroup>
                        <h:panelGroup style="float: left;">
                            Usuario
                        </h:panelGroup>
                        <h:panelGroup style="float: right;">
                            <ice:form>
                            <h:commandButton image="/resources/images/popup-close.png"
                                            alt="Cerrar" title="Cerrar"
                                            style="height: 11px; width: 11px; border: 0;"
                                            action="#{usuariosBean.closePopup}"/>
                            </ice:form>
                        </h:panelGroup>
                    </h:panelGroup>
                </f:facet>
                <f:facet name="body">
                    <ice:form id="usuarioForm">
                        <ice:panelGrid columns="2">
                            <p>Nombre:</p>
                            <ice:inputText id="nombre" label="nombre" value="#{usuariosBean.usuario.nombre}" size="40" />
                            <p>Imagen:</p>
                            <ice:graphicImage value="#{usuariosBean.usuario.imagen}"/>
                            <ace:fileEntry id="fileEntryImage" absolutePath="c:\iTablero\imagenes"
                                            useSessionSubdir="false" useOriginalFilename="false"
                                            fileEntryListener="#{usuariosBean.formListener}"/>
                            <h:commandButton type="submit" value="Subir archivo"/>
                        </ice:panelGrid>
                        <ice:messages for="usuarioForm"/>
                        <ice:commandButton value="Guardar" action="#{usuariosBean.save()}" />
                    </ice:form>
                </f:facet>                    
            </ice:panelPopup>

UsuariosBean.java

package com.itablero.backingbeans;

import com.itablero.excepciones.DAOException;
import com.itablero.modelo.Usuario;
import com.itablero.servicios.AdminService;
import java.io.Serializable;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;
import org.icefaces.ace.component.fileentry.FileEntry;
import org.icefaces.ace.component.fileentry.FileEntryEvent;
import org.icefaces.ace.component.fileentry.FileEntryResults;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;

@ManagedBean
@Controller
@ViewScoped
public class UsuariosBean implements Serializable {

@Autowired
private AdminBean adminBean;
@Autowired
private AdminService adminService;
private Usuario usuario = new Usuario();
private boolean showPopup;

//getter and setters 

public boolean isShowPopup() {
    return showPopup;
}

public void setShowPopup(boolean showPopup) {
    this.showPopup = showPopup;
}


public void openPopup() {
    this.showPopup = true;
}

public void closePopup() {
    this.showPopup = false;
    this.usuario = new Usuario();
}

public String edit(Usuario usuario) {
    this.usuario = usuario;
    this.showPopup = true;
    return "usuariosList";
}

public String delete(Usuario usuario) {
    adminService.delete(usuario);
    return "usuariosList";
}

public String save() {
    try {
        usuario.setTutor(adminBean.getLoggedTutor());
        adminService.save(usuario);
    } catch (DAOException ex) {
        Logger.getLogger(TutoresBean.class.getName()).log(Level.SEVERE, null, ex);
    }
    usuario = new Usuario();
    this.showPopup = false;
    return "usuariosList";
}

public void formListener(FileEntryEvent e) {
    System.out.println("Entro");
    FileEntry fe = (FileEntry)e.getComponent();
    FileEntryResults results = fe.getResults();
    //other stuff
}

}

更新 2

うまくいかない理由はわかったと思いますが、修正には助けが必要です。@fischermatte のアドバイスに従って修正を加えましたが、うまくいきませんでした。

フォームを使用してこのページにアクセスするには、まずメイン ページに移動する必要があります。/admin/admin.htmlブラウザで URL が表示される場合は、http://localhost:8084/iTablero/admin/admin.htmlこのページにはメニューがあり、このメニュー オプションの 1 つを使用すると、問題のあるフォームのページに移動します。しかし、(私が間違っていなければ) AJAX 呼び出しであるため、ブラウザーの URL は変更されず、http://localhost:8084/iTablero/admin/admin.html. また、fileEntry がリスナーを呼び出すことはありません。これで、自分http://localhost:8084/iTablero/admin/usuariosList.htmlで URL を入力すると、以前と同じようにページが正しく表示されますが、FILEENTRY が完全に機能するようになりました!!! これを修正する方法がわかりません。リダイレクトを使用する必要がありますか? 私はAJAXの周りに何かがあると思います.......助けてください!:-D


アップデート 3

それがメニューです。リダイレクトなしでは機能しません。

       <h:form>
            <ice:menuBar orientation="horizontal">
                <ice:menuItem value="Tutores" action="tutoresList"/>
                <ice:menuItem value="Usuarios" action="usuariosList"/>
                <ice:menuItem value="Tableros" action="tablerosList"/>
                <ice:menuItem value="Simbolos" action="simbolosList"/>
                <ice:menuItem value="Estadisticas" action="estadisticas"/>
                <ice:menuItem value="Salir" action="#{adminBean.logout()}"/>
            </ice:menuBar>
       </h:form>

正常にaction="usuariosList?faces-redirect=true"動作します。FileEntry のみを使用して基本的なページ フォームへのフォワード ナビゲーションを既にテストしており、機能しません。繰り返しますが、リダイレクトを使用すると、正常に動作します。このコンポーネントと前方ナビゲーションに何らかの問題があると思います。

4

1 に答える 1

0

icefacesの代わりにJSFのコマンドボタンを使用する必要があります<h:commandButton type="submit" value="Subir archivo"/>。これはICEFacesの既知の問題です。ace :fileEntrywikiを参照してください。

アップデート1

さらに、ポップアップでレンダリングされた属性を削除するか、次のようにポップアップを開くときにポップアップを更新します。

<h:form>
    <h:commandButton value="Show Popup" action="#{usuariosBean.showPopupAction}">
        <f:ajax render=":popupPanelGroup"/>
    </h:commandButton>
</h:form>
<h:panelGroup id="popupPanelGroup">
    <ice:panelPopup visible="#{usuariosBean.showPopup}" rendered="#{usuariosBean.showPopup}" modal="true" autoCentre="true">
     ...
    </ice:panelPopup>
</h:panelGroup>
于 2012-04-10T21:00:04.730 に答える