Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/image/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Image p:galleria没有显示任何图像_Image_Jsf_Primefaces_Galleria - Fatal编程技术网

Image p:galleria没有显示任何图像

Image p:galleria没有显示任何图像,image,jsf,primefaces,galleria,Image,Jsf,Primefaces,Galleria,我使用primefaces p:galleria来显示一些图像,但是它根本没有显示任何东西 <p:galleria value="#{galleriaBean.images}" var="image" effect="slide" effectSpeed="1000"

我使用primefaces p:galleria来显示一些图像,但是它根本没有显示任何东西

                <p:galleria value="#{galleriaBean.images}" 
                            var="image" 
                            effect="slide" 
                            effectSpeed="1000"
                            panelWidth="500" 
                            panelHeight="313" 
                            showCaption="false">  

                    <p:graphicImage value="/resources/Tutorial/#{image}" 
                                    alt="Image Description for #{image}" 
                                    title="#{image}"/>  
                </p:galleria> 
但是init被称为:D

编辑:现在将其归结为1个错误:

WARNING: Setting non-serializable attribute value into ViewMap: (key: galleriaBean, value class: richard.fileupload.GalleriaBean)
当前代码:我现在没有收到任何错误,但也没有显示任何内容

  /*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package richard.fileupload;

import java.io.Serializable;
import java.util.ArrayList;  
import java.util.List;  
import javax.annotation.PostConstruct; 
import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;
import javax.faces.bean.ViewScoped;
import javax.faces.context.FacesContext;
/**
 *
 * @author Richard
 */

@ManagedBean(name="galleriaBean")
//@RequestScoped
@ViewScoped

public class GalleriaBean implements Serializable {  

    public static List<String> images;  


    @PostConstruct  
    public void init() {  
        FacesContext.getCurrentInstance().getExternalContext().getSession(true);
        System.out.println("init called"); //testing to see if it called, currently causing a lot of errors
        images = new ArrayList<String>();  

        for(int i=1;i<=3;i++) {  
             System.out.println("loop called"); //testing to see if it called, currently causing a lot of errors
            images.add("/resources/Tutorial/"+ i +".jpeg");
        }  
    }  

    public List<String> getImages() {  
        System.out.println("getImages called"); //testing to see if it called, currently causing a lot of errors
        return images;  
    }

}
全部调用,但仍不显示任何内容

编辑:

感谢您的帮助,我已经按照您的建议更改了文件位置,并在chrome中检查了控制台,您是对的,我收到了404 not found错误,但即使在更改到您的位置后,我也会收到此错误

我的文件目录是

WebContent
 |-- META-INF
 |-- WEB-INF
 |-- GUI
 |    `-- tutorial.xhtml (page calling the images)
 |-- resources
 |    `-- Tutorial
 |         |-- Tutorial1.jpg
 |         |-- Tutorial2.jpg
 |         |-- Tutorial3.jpg
 |         :   :
 |
然而,使用chromes控制台,我可以看到它正试图在
/fileuploadWithPreview//GUI/Tutorial/Tutorial
中查找图像,但它们存储在
参考资料/Tutorial/


新的问题是如何让它调用GUI文件夹之外的resources文件夹xhtml文件所在的文件夹图像URL至少非常奇怪

这里,

两次
/resources
?这似乎不对。如果您已经注意到webbrowser的开发者工具集中的HTTP流量(在Chrome/IE9/Firebug中按F12),那么您应该已经注意到浏览器在所有这些图像上接收到404 Page Not Found错误。另外,如果您已经注意到生成的HTML
元素的
src
,您应该已经注意到有些地方不正确

假设您在
/resources/Tutorial
文件夹中有
Tutorial[n].jpg
图像

WebContent
|--META-INF
|--WEB-INF
|--资源
|`--教程
||--Tutorial1.jpg
||--Tutorial2.jpg
||--Tutorial3.jpg
|         :   :
|
`--page.xhtml
然后,您应该准备图像文件名,如下所示:

for(int i=1;i<=25;i++) {  
    images.add("Tutorial"+i+".jpg");
}

至于PWC3999例外,这涉及一个完全不同的问题。如何解决它,请看。换句话说,只需升级Mojarra即可


至于非序列化属性警告,只需让提到的类实现
serializable

图像URL至少非常奇怪

这里,

两次
/resources
?这似乎不对。如果您已经注意到webbrowser的开发者工具集中的HTTP流量(在Chrome/IE9/Firebug中按F12),那么您应该已经注意到浏览器在所有这些图像上接收到404 Page Not Found错误。另外,如果您已经注意到生成的HTML
元素的
src
,您应该已经注意到有些地方不正确

假设您在
/resources/Tutorial
文件夹中有
Tutorial[n].jpg
图像

WebContent
|--META-INF
|--WEB-INF
|--资源
|`--教程
||--Tutorial1.jpg
||--Tutorial2.jpg
||--Tutorial3.jpg
|         :   :
|
`--page.xhtml
然后,您应该准备图像文件名,如下所示:

for(int i=1;i<=25;i++) {  
    images.add("Tutorial"+i+".jpg");
}

至于PWC3999例外,这涉及一个完全不同的问题。如何解决它,请看。换句话说,只需升级Mojarra即可



至于非序列化属性警告,只需让所提到的类实现
serializable

您的类
GaleriaBean
根本不是托管bean。你能在类中添加
@ManagedBean
@viewscope
注释并查看发生了什么吗?编辑到上面的内容,仍然没有图像,但它为itBean创建了空间不能同时被请求范围和视图范围限制!?尝试删除请求范围,并在
init
方法中添加断点,以查看它是否执行。使用结果更新原始q首先通过实现serializable接口使bean可序列化,然后在init方法的开头添加此行:
FacesContext.getCurrentInstance().getExternalContext().getSession(true)
youclass
GaleriaBean
根本不是托管bean。你能在类中添加
@ManagedBean
@viewscope
注释并查看发生了什么吗?编辑到上面的内容,仍然没有图像,但它为itBean创建了空间不能同时被请求范围和视图范围限制!?尝试删除请求范围,并在
init
方法中添加断点,以查看它是否执行。使用结果更新原始q首先通过实现serializable接口使bean可序列化,然后在init方法的开头添加此行:
FacesContext.getCurrentInstance().getExternalContext().getSession(true)谢谢你的回答,但是新的问题是如何让它调用GUI文件夹之外的resources文件夹xhtml文件是已经回答过的。使用
名称
属性。它相对于
/resources
文件夹进行解析。另请参见其他内容谢谢,我尝试在
中使用
名称
,您使用的是什么PF版本?在任何情况下,只需将
p:
替换为
h:
。它肯定支持它。显然,他们在旧版本中忽略了它。至少在中是受支持的。谢谢您的回答,但是新的问题是如何让它调用GUI文件夹之外的resources文件夹xhtml文件位于已回答的文件夹中。使用
名称
属性。它相对于
/resources
文件夹进行解析。另请参见其他内容谢谢,我尝试在
中使用
名称
,您使用的是什么PF版本?在任何情况下,只需将
p:
替换为
h:
。它肯定支持它。显然,他们在旧版本中忽略了它。它至少在中得到了支持。
WebContent
 |-- META-INF
 |-- WEB-INF
 |-- GUI
 |    `-- tutorial.xhtml (page calling the images)
 |-- resources
 |    `-- Tutorial
 |         |-- Tutorial1.jpg
 |         |-- Tutorial2.jpg
 |         |-- Tutorial3.jpg
 |         :   :
 |
for(int i=1;i<=25;i++) {  
    images.add("/resources/Tutorial"+i+".jpg");
}
<p:graphicImage value="/resources/Tutorial/#{image}" ... />
for(int i=1;i<=25;i++) {  
    images.add("Tutorial"+i+".jpg");
}
<p:graphicImage name="Tutorial/#{image}" ... />