我在JSF上传文件.我正在使用Tomahawk <t:inputFileUpload>,但同样的问题适用于例如PrimeFaces <p:fileUpload>和JSF 2.2 <h:inputFile>.
我有以下支持bean代码:
private UploadedFile uploadedFile; // +getter+setter
public String save() throws IOException {
String name = uploadedFile.getName();
System.out.println("File name: " + name);
String type = uploadedFile.getContentType();
System.out.println("File type: " + type);
long size = uploadedFile.getSize();
System.out.println("File size: " + size);
InputStream stream = uploadedFile.getInputStream();
byte[] buffer = new byte[(int) size];
stream.read(buffer, 0, (int) size);
stream.close();
}
Run Code Online (Sandbox Code Playgroud)
我能够获取文件名,类型和大小,但我无法将此文件保存在特定路径中.我无法找出保存上传文件的正确方法.我怎样才能做到这一点?
我正在使用JSF1.1,我想从第一个更新第二个selectOneMenu并拥有此代码_
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
<%@ taglib uri="http://www.azureworlds.org" prefix="azure"%>
<%@ taglib uri="http://myfaces.apache.org/tomahawk" prefix="x"%>
<%@ taglib uri="http://www.asifqamar.com/jsf/asif" prefix="a"%>
Run Code Online (Sandbox Code Playgroud)
...
<h:outputText value="State* " />
<x:selectOneMenu value="#{hotelBean.state}">
<f:selectItem itemLabel="Select One" itemValue="" />
<f:selectItem value="#{hotelBean.mapStates }" />
<x:ajax update="city" listener="#{hotelBean.handleCityChange}" />
</x:selectOneMenu>
<h:outputText value="City* " />
<x:selectOneMenu id="city" value="#{hotelBean.city}">
<f:selectItem itemLabel="Select One" itemValue="" />
<f:selectItem value="#{hotelBean.mapCities }" />
</x:selectOneMenu>
Run Code Online (Sandbox Code Playgroud)
第x行:ajax update ="city"listener ="#{hotelBean.handleCityChange}" 无法正常工作,我搜索但JSF1.1不支持Ajax.
那我该怎么办呢,我怎么能用javascript?我对JS的了解较少.感谢名单
我正在使用<p:dataTable>我使用的HTML <table>.我想<p:inputText>在<h:selectOneMenu>更改事件上禁用/ readonly PrimeFaces .
我使用的是JavaScript,但它没有使用它.
<script type="text/javascript">
function change(val)
{
//alert(val);
if(val=="Check")
{
document.getElementById('bankName').readonly=false;
document.getElementById('receiptNo').readonly=true;
}
if(val=="Cash")
{
forms.elements["mainForm:chkNo"].readonly=true;
document.getElementById('chkNo').readonly=true;
document.getElementById('bankName').readonly=true;
document.getElementById('receiptNo').readonly=false;
}
}
</script>
Run Code Online (Sandbox Code Playgroud)
JSF代码
<h:column>
<p:dataTable id="paymentHistoryDataTable" var="due"
>
<p:column>
.......
Run Code Online (Sandbox Code Playgroud)
<table id="paymentProcess">
<tr>
<td style="width: 80px;">
<h:selectOneMenu value="#{adminActionController.tempBean.selectType}" id="type" onchange="change(this.value);">
<f:selectItem itemLabel="Check" itemValue="Check"/>
<f:selectItem itemLabel="Cash" itemValue="Cash"/>
</h:selectOneMenu>
</td>
</tr>
<tr id="check">
<td></td>
<td></td>
<td style="width: 90px;" id="lblChk">
<label> <h:outputText value="Check/DD Number:" /> </label>
</td>
<td style="width: 90px;">
<h:inputText id="chkNo" …Run Code Online (Sandbox Code Playgroud) 我正在使用GlassFish服务器的Java项目.项目中没有错误但是当我试图运行它时,它显示此错误_
SEVERE: DPL8015: Invalid Deployment Descriptors in Deployment descriptor file WEB-INF/web.xml in archive [web].
Line 9 Column 22 -- cvc-complex-type.2.4.d: Invalid content was found starting with element 'description'. No child element is expected at this point.
SEVERE: DPL8005: Deployment Descriptor parsing failure : cvc-complex-type.2.4.d: Invalid content was found starting with element 'description'. No child element is expected at this point.
SEVERE: Exception while deploying the app
java.io.IOException: org.xml.sax.SAXParseException: cvc-complex-type.2.4.d: Invalid content was found starting with element 'description'. No child element …Run Code Online (Sandbox Code Playgroud) jsf ×3
javascript ×2
ajax ×1
file-upload ×1
glassfish ×1
glassfish-3 ×1
java ×1
jsf-2 ×1
primefaces ×1
save ×1