我正在使用<t:inputFileUpload />JSF1.1控制Tomahawk库.相应地设置我的扩展名过滤器和表单,以允许上载最大3 MB的文件.但问题是如果一个文件超过3 MB,表单不会被提交,但会再次显示,我无法<h:message>为它设置任何内容.
那么如何告诉用户文件上传失败.
我试过保持,<h:messages globalOnly="true"但没有显示任何东西.
我按照BalusC博客文章设置了我的上传内容.
我想根据条件更改行的背景颜色.
<t:dataTable id="data"
styleClass="history-table"
headerClass="history-table-header"
rowClasses="history-table-row-default"
border="2" cellpadding="5" cellspacing="2"
var="entry"
value="#{historyBean.logEntryList}"
preserveDataModel="false"
rows="#{historyBean.history.rowCount}"
sortable="true">
<h:column>
<f:facet name="header">
<h:outputText value="Debug Status" />
</f:facet>
<h:outputText value="#{entry.action}" />
</h:column>
Run Code Online (Sandbox Code Playgroud)
如果"entry.action"值十一喜欢用"历史表 - 行 - 未完成"(的styleClass的名字),如果该值是YI喜欢用"历史表 - 行 - 错误"的styleClass的(名).所有其他情况应使用默认值.
我想我必须以某种方式获取当前的入口对象到我的bean,分析它并返回一个带有stylclass名称的字符串到outputText来改变颜色.但我不知道如何......(我是JSF的新人...)
有谁可以帮助我吗?
我正在将图像上传到服务器,当图像上传时,它应该向我显示上传图像的拇指.缩略图未保存在硬盘上我使用InputStream和OutputStream.对于上传我是ustig tomahawk.
我的index.jsp:
<h:form id="uploadForm" enctype="multipart/form-data">
<t:inputFileUpload id="fileupload"
accept="image/*"
storage="file"
value="#{fileUpload.uploadedFile}"
styleClass="fileUploadInput"
required="true"
validator="epacient.FileUploadValidator"
requiredMessage="Obvezna izbira datoteke."
/>
<br />
<h:message for="fileupload" infoStyle="color: green;"
errorStyle="color: red;" />
<br />
<h:commandButton value="Upload" id="fileUploadButton"
action="#{fileUpload.upload}" />
<h:message for="uploadForm" style="color: red;" />
<h:graphicImage value="#{fileUpload.thumb}"
rendered="#{fileUpload.uploaded}" />
</h:form>
Run Code Online (Sandbox Code Playgroud)
fileUpload.upload调用函数 String preview()
private String thumb ;
public String preview() throws IOException{
HttpServletResponse response = (HttpServletResponse)FacesContext
.getCurrentInstance().getExternalContext().getResponse();
try {
FacesContext context = FacesContext.getCurrentInstance();
Map requestMap = context.getExternalContext().getApplicationMap();
byte[] bytes = (byte[])(requestMap.get("fileupload_bytes"));
// returns byte[]
byte[] testByte …Run Code Online (Sandbox Code Playgroud) 你知道这个主题中提到的标签有什么区别吗?
我认为他们应该产生几乎相同的结果但事实证明,在某些情况下ui:repeat(facelets标签)没有像你期望的那样工作,尽管它也被认为是一个基本的迭代组件.
t是tomahawk和a4j是一个richfaces前缀.
欢迎任何评论.
JSF:
...
xmlns:t="http://myfaces.apache.org/tomahawk">
<t:panelGrid columns="4">
...
</t:panelGrid>
Run Code Online (Sandbox Code Playgroud)
它使用tr's td' 和's元素动态生成普通的旧HTML表.
如何为这些tr和/或td元素设置特定的CSS样式?
我有哪些选项可以从JSP页面中读取当前用户的角色?我知道visibleOnUserRole="myRole"Tomahawk组件的属性,但我需要角色来处理比简单可见性更复杂的事情.
将tomahawk-1.1.11.jar文件添加到我的web应用程序的WEB-INF/lib并收到错误消息:
Exception sending context initialized event to listener instance of class
com.sun.faces.config.ConfigureListener:
java.lang.RuntimeException:java.lang.LinkageError: Failed to link
org/apache/myfaces/custom/aliasbean/AliasBeanTagHandler
Caused by: java.lang.ClassNotFoundException: com.sun.facelets.tag.jsf.ComponentHandler
from [Module "deployment.appFramework.war:main" from Service Module Loader]
Run Code Online (Sandbox Code Playgroud)
什么想法可能是错的?
堆栈跟踪:
10:44:14,813 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].
[/appFramework]] (MSC service thread 1-7) Exception sending context initialized event
to listener instance of class
com.sun.faces.config.ConfigureListener:java.lang.RuntimeException:
java.lang.LinkageError: Failed to link org/apache/myfaces/custom/aliasbean
/AliasBeanTagHandler (Module "deployment.appFramework.war:main" from Service Module
Loader)
at
com.sun.faces.config.ConfigureListener.contextInitialized(ConfigureListener.java:292)
[jsf-impl-2.1.3-b02-jbossorg-2.jar:2.1.3-SNAPSHOT]
at
org.apache.catalina.core.StandardContext.contextListenerStart
(StandardContext.java:3368)
[jbossweb-7.0.1.Final.jar:7.0.2.Final]
at org.apache.catalina.core.StandardContext.start(StandardContext.java:3821)
[jbossweb-7.0.1
.Final.jar:7.0.2.Final]
at
org.jboss.as.web.deployment.WebDeploymentService.start(WebDeploymentService.java:70)
[jboss-as-web-7.0.2.Final.jar:7.0.2.Final]
at
org.jboss.msc.service.ServiceControllerImpl$StartTask.startService
(ServiceControllerImpl.java:1824)
at
org.jboss.msc.service.ServiceControllerImpl$StartTask.run …Run Code Online (Sandbox Code Playgroud) 我正在使用 myfaces ExtensionFilter 上传文件,但该文件未设置到我的 bean 中以供进一步处理。
这是代码:
<h:form id="uploadFileForm" enctype="multipart/form-data">
<tom:inputFileUpload id="file"
value="#{paramUpload.uploadFile}">
<f:valueChangeListener type="com.bosch.de.plcd.plugin.ParamFileUpload" />
</tom:inputFileUpload>
<a4j:commandButton value="#{tpMsgs.upload}"
styleClass="button" action="#{paramUpload.uploadParamFile}"
onclick="javascript:updateParentScreen();">
</a4j:commandButton>
</h:form>
Run Code Online (Sandbox Code Playgroud)
web.xml配置如下
<filter>
<filter-name>Extensions Filter</filter-name>
<filter-class>org.apache.myfaces.webapp.filter.ExtensionsFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>Extensions Filter</filter-name>
<servlet-name>Faces Servlet</servlet-name>
</filter-mapping>
Run Code Online (Sandbox Code Playgroud)
由于UploadFile没有设置为 bean,我也尝试使用 ValueChangeListener,尽管如此,它不是 bean :)
豆码
public class ParamFileUpload implements ValueChangeListener {
private UploadedFile uploadFile;
public void uploadParamFile() {
if(uploadFile != null) {
LOGGER.info("File type: " + uploadFile.getContentType());
LOGGER.info("File name: " + uploadFile.getName());
LOGGER.info("File size: " + uploadFile.getSize() + " bytes");
} …Run Code Online (Sandbox Code Playgroud) 我正在使用Tomahawk inputFileUpload组件来允许用户将文件上传到服务器.我通过在上传文件后检查文件大小来实现"软"文件大小限制,如果文件太大则显示错误.但是我还想要一个更大的"硬"限制,一旦超过限制,上传会立即停止.例如,如果硬限制为500MB并且用户尝试上载2GB文件,则一旦上载500MB并且显示错误,上载将立即停止.
我曾希望使用MyFaces ExtensionsFilter并设置uploadMaxFileSize可以解决问题,但是在抛出SizeLimitExceededException之前,文件已完全上传.
是否有可能做到这一点?理想情况下,我仍然可以使用战斧,但任何其他解决方案都会很好.
我是JSF 1.2的新手,我试图将一些文本输出到我的javascript调用中
something(<t:outputText value="#{bean.val}"/>)
Run Code Online (Sandbox Code Playgroud)
但不是获得纯文本输出,而是全部包含在一个范围内.我如何摆脱跨度?
我有以下页面使用JSF将.pdf文件上传到服务器上指定的文件夹.但是,commandButton操作似乎根本没有触发,因为我的println()没有显示,也没有消息更新.如果有人能解释这个问题,我们将不胜感激.
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:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:t="http://myfaces.apache.org/tomahawk"
xmlns:f="http://java.sun.com/jsf/core" xml:lang="en" lang="en">
<head>
<meta http-equiv="keywords" content="enter,your,keywords,here" />
<meta http-equiv="description"
content="A short description of this page." />
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<link rel="stylesheet" type="text/css" href="Styles/style.css" />
<script type="text/javascript" src="http://ajax.microsoft.com/ajax/jquery/jquery-1.7.2.min.js"></script>
</head>
<body>
<h:form enctype="multipart/form-data">
<h:outputText value="First Name: " />
<h:inputText id="fname" size="40" value="#{userBean.firstName}" required="true"/> <br/>
<h:outputText value="Last Name: " />
<h:inputText id="lname" size="40" value="#{userBean.lastName}" required="true"/> <br/>
<h:outputText value="Position Sought: "/>
<h:inputText id="position" …Run Code Online (Sandbox Code Playgroud) 我正在使用 Tomahawk 的 fileupload 组件<t:inputfileupload>来上传文件。我已将表单的 enctype 设置为
enctype="multipart/form-data"
Run Code Online (Sandbox Code Playgroud)
我曾经<h:commandButton>提交过表格。
但是UploadedFilebean 中的属性是null. 我做错了什么,我该如何解决?
我想构建一个表单,根据其他组件的状态动态更改可见的组件.
例如......有一些文本框和一些复选框,如果用户激活某个复选框,则应显示一堆其他输入元素.
我可以使用JSF 2.0 + Tomahawk执行此操作,还是必须使用另一个库来执行此操作?我怎么能这样做?没有AJAX,这将无法工作,是吗?
提前致谢!