小编nik*_*gra的帖子

如何在jBoss AS 7中配置静态资源

我想将图像上传到服务器,将它们存储在文件系统(服务器外部)中,然后在我的JSF页面上显示它们.

我想找到这样的东西:

<?xml version="1.0" encoding="UTF-8"?>
<Context allowLinking="true" cookies="true" crossContext="true" override="true">
    <Resources allowLinking="true"
        className="com.triplemind.site.engine.SourceResolverContext"
        homeDir="/home/myapp/files" />
</Context>   
Run Code Online (Sandbox Code Playgroud)

我找到了一些解决方案,但我想知道是否有更好的方法来做到这一点.

  1. 在JBOSS AS 7中配置静态资源(未回答)
  2. 在AS7中替换context.xml?访问WAR以外的文件?(无解答)

我发现有jBoss文档:

  1. static-resources元素
  2. AdminGuide容器配置

任何帮助将不胜感激.提前致谢

java jboss staticresource jboss7.x

10
推荐指数
1
解决办法
8355
查看次数

Apache Camel根据请求丰富了带有文件内容的消息

我正在实现RESTful服务(使用CXFRS组件),它应返回某些请求的文件.每个文件都由其id和扩展名提取,即restfulservice.com/path/file/1/pdf.添加的每个文件永远不会更改.提取后不应移动或删除文件,通常应同时访问它们.这是我的Camel上下文的一部分:

from("direct:fetchFile")
    .process(fetchFileProcessor) // set file.id & file.extension
    .bean(fileService, "fetchFile(${header.file.id}, ${header.file.extension})") // set body to filename
    .setHeader("CamelFileName", simple("${body}"))
    .choice()
        .when(header("file.extension").isEqualTo("xml"))
            .pollEnrich("file:///{{application.fileStorage.basePath}}/xml?noop=true", 500)
        .when(header("file.extension").isEqualTo("pdf"))
            .pollEnrich("file:///{{application.fileStorage.basePath}}/pdf?noop=true", 500)
    .end()
    .convertBodyTo(File.class)
    .bean(responseProvider, "getResponse(${body}, 200)");
Run Code Online (Sandbox Code Playgroud)

此配置的问题是响应仅为第二个(为什么?)请求具有非空主体,没有超时设置服务在第二个请求上使用调试消息进入永久循环

DEBUG o.a.c.c.f.FileConsumer - Took 0.000 seconds to poll <base path>\xml
Run Code Online (Sandbox Code Playgroud)

Apace Camel版本是2.10.4

任何帮助,将不胜感激

UPD1:Content Enricher页面
上有警告,说'pollEnrich不访问当前Exchange的任何数据'.但是,如果添加到文件URL,则没有任何变化fileName=${body}

UPD2:
看起来pollEnrich不支持fileNameURL(链接)中指定的动态.目前的路线:

from("direct:fetchFile")
    .process(fetchFileProcessor) // set file.id & file.extension
    .bean(fileService, "fetchFile(${header.file.id}, ${header.file.extension})") // set body to filename
    .choice()
        .when(header("file.extension").isEqualTo("xml"))
            .pollEnrich("file:///{{application.fileStorage.basePath}}/xml?fileName=${body}&noop=true", 500)
            .setHeader("asset.type", simple(MediaType.APPLICATION_XML)) …
Run Code Online (Sandbox Code Playgroud)

java rest cxf apache-camel java-ee

6
推荐指数
1
解决办法
1万
查看次数

动态添加Primefaces组件

我想动态添加Primefaces组件.我正在使用与此类似的解决方案,前面已经讨论过:

<h:form>
    <h:panelGrid columns="2">
        <p:dataGrid id="categoriesGrid" value="#{bean.categories}"
            var="categoryBean" rowIndexVar="rowIndex">
            <p:column>
                <p:selectOneMenu id="categorySelect" effect="drop"
                    value="#{categoryBean.selectedCategory}" >
                    <f:selectItems value="#{categoryBean.availableCategories}"
                        var="category" itemLabel="#{category.name}"
                        itemValue="#{category}" />
                </p:selectOneMenu>
            </p:column>
        </p:dataGrid>
        <p:commandButton actionListener="#{bean.addNewCategory}"
            value="Add category" update="categoriesGrid"/>
    </h:panelGrid>
</h:form>
Run Code Online (Sandbox Code Playgroud)

但它有问题.在点击"添加类别"按钮后,我得到了回复示例:

<?xml version='1.0' encoding='UTF-8'?>
<partial-response>
<error>
    <error-name>
        class javax.faces.component.UpdateModelException
    </error-name>
    <error-message>
        <![CDATA[/createTutorial.xhtml @85,65 value=
            "#{categoryBean.selectedCategory}":java.util.NoSuchElementException]]>
    </error-message>
</error>
</partial-response>
Run Code Online (Sandbox Code Playgroud)

提前致谢

java jsf selectonemenu java-ee primefaces

5
推荐指数
1
解决办法
5557
查看次数

如何将JSF组件绑定到支持bean属性

我有一个绑定p:commandButton到支持bean中的属性的问题.我试图简化我的代码以显示一般的想法.

ExampleBean是一个辅助bean

public class ExampleBean {

    public String title;        
    List<ExampleWrapper> list;

    // Getters and setters

}
Run Code Online (Sandbox Code Playgroud)

ExampleWrapper是一个POJO

public class Wrapper {

    public String name;
    public String description;

    public CommandButton button;

    // Listener which changes button state

    // Getters and setters
}
Run Code Online (Sandbox Code Playgroud)

index.xhtml是一个主页面:

<h:form>
    <h:outputText value="Title" />
    <p:inpurText value="#{exampleBean.title}"

    <ui:include src="list.xhtml">
        <ui:param name="bean" value="#{exampleBean}">
    </ui:include>
</h:form>
Run Code Online (Sandbox Code Playgroud)

list.xhtml是一个我想在几个地方重用的片段:

<ui:composition ...>
    <ui:repeat id="list" var="exampleWrapper" value="#{bean.list}">
        <h:outputText value="#{exampleWrapper.name}"/>
        <h:outputTextarea value="#{exampleWrapper.description}"/>
        <p:commandButton id="button" binding="#{exampleWrapper.button}" 
            value="Button" />
</ui:composition>
Run Code Online (Sandbox Code Playgroud)

所以,我得到异常:javax.el.PropertyNotFoundException:/list.xhtml ... binding ="#{exampleWrapper.button}":目标无法访问,标识符'exampleWrapper'解析为null

没有binding …

java jsf binding java-ee primefaces

3
推荐指数
1
解决办法
2万
查看次数