ICEfaces的3.0.1 FileEntry:FileEntryListener不会被调用 [英] Icefaces 3.0.1 FileEntry: FileEntryListener is never called

查看:162
本文介绍了ICEfaces的3.0.1 FileEntry:FileEntryListener不会被调用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

1.1,ICEfaces的3.0.1和JSF 2.1,并且正在努力工作,王牌:fileentry。我不明白为什么监听器永远不会被调用!即使是IDE送了我一个警告pruebaBean.sampleListener是一个未知属性。 下面是我在做什么一个简短的例子。当点击提交按钮没有发生。 有人可以帮我吗?可能是某种错误的?

1.1, IceFaces 3.0.1 and JSF 2.1 and was trying to work with ace:fileentry. I can't understand why the listener is never called! Even the IDE sends me a warning "pruebaBean.sampleListener is an unknown property". Here is a short example of what i'm doing. When click the submit button nothing happen. Can someone help me ?? Could be some kind of bug?

prueba.xhtml:

prueba.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:

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我发现这个问题是替代冰:对的commandButton H:命令按钮。但是,当我申请这原本完整的形式,并没有工作。该fileEntryListener方法不会被调用。有人可以看到错误吗? 在逻辑上,previous例子,下面的code具有相同的web.xml中,faces-config.xml中,等等。请注意按钮提交文件是H:命令按钮,和有一个冰:的commandButton完整形成。我已经尝试过改变这种POR EN H:CB。 这里是原始形式(即在一个弹出/模态窗口显示)和豆制品:


Update 1

Thanks to @fischermatte I found the problem was replace ice:commandButton for h:commandButton. But when I applied this to the original complete form and didn't work. The fileEntryListener method is never called. Can someone see the error here? Logically the previous example and the code below have the same web.xml, faces-config.xml, etc. Note the button to submit the file is h:commandButton, and there is a ice:commandButton for complete form. I already tried to change this por en h:cb. Here is the original form (that is display in a popup/modal window) and bean:

usuariosList.xhtml

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

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建议我,但没有奏效。


Update 2

I think I figured out why is not working, but need some help with the fix. I made the corrections as @fischermatte advice me, but didn't work.

要达到这个网页的形式,首先必须导航抛出主页 /admin/admin.html ,如果看的URL在浏览器中出现的http://本地主机:8084 / iTablero /管理/ admin.html 。此页面有一个菜单,此菜单选项带给我的页面有问题的形式之一。但是,由于是AJAX调用(如果我没有错),在浏览器的网址不会改变,它使的http://本地主机:8084 / iTablero /管理/ admin.html 。而fileEntry从未调用监听器。 现在,如果我通过自己输入网址的http://本地主机:8084 / iTablero /管理/ usuariosList.html ,正确显示网页和以前一样,但现在FILEENTRY完美的作品! 我不知道如何解决这个问题,将不得不使用重定向?我想围绕AJAX的东西.......帮助请! - D

To reach this page with the form, first have to navigate throw a the main page /admin/admin.html, if a look the URL in the browser appears http://localhost:8084/iTablero/admin/admin.html. This page has a menu, one of this menu options bring me to the page with the problematic form. But, because is an AJAX call (if i'm not wrong) the URL in the browser does not change, it keeps the http://localhost:8084/iTablero/admin/admin.html. And the fileEntry never calls the listener. Now, if I enter the URL by myself http://localhost:8084/iTablero/admin/usuariosList.html, the page is displayed correctly as before, but now THE FILEENTRY WORKS PERFECTLY!!! I have no idea how to fix this, will have to use redirects? I think is something around AJAX.......help pls! :-D

这是菜单,无需重定向无法正常工作。

That is the menu, without redirect is not working.

       <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>

使用行动=usuariosList?面临重定向=真正的工作正常。 与前进导航已经考到一个基本的网页形式,只有一个FileEntry并不起作用了。同样,如果我使用重定向,做工精细。我认为这是某种形式的问题与此组件和前进导航。

With action="usuariosList?faces-redirect=true" works fine. Already test with forward navigation to a basic page form with only a FileEntry and doesn't work too. Again, if I use redirect, works fine. I think is some kind of issue with this component and forward navigation.

推荐答案

您必须使用的ICEfaces的JSF的命令来代替:&LT; H:的commandButton类型=提交值=苏比尔archivo/ &GT; 。这是ICEFaces的一个已知的问题,请参见王牌:fileEntry维基

You have to use JSF's commandbutton instead of icefaces's: <h:commandButton type="submit" value="Subir archivo"/>. It is a known issue in ICEFaces, see ace:fileEntry wiki.

更新1

另外,你要么喜欢在这里打开时,它取出,在弹出的呈现属性或更新弹出:

Plus you either remove the rendered attribute in the popup or update the popup when opening it like here:

<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>

这篇关于ICEfaces的3.0.1 FileEntry:FileEntryListener不会被调用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆