WW-5461 Extends UploadedFile with inputName field

This commit is contained in:
Lukasz Lenart
2024-09-03 07:40:17 +02:00
parent b69e44122d
commit b237fb6f88
9 changed files with 82 additions and 28 deletions
@@ -37,6 +37,7 @@ public class FileUploadAction extends ActionSupport implements UploadedFilesAwar
private String fileName;
private String caption;
private String originalName;
private String inputName;
public String input() throws Exception {
return SUCCESS;
@@ -58,6 +59,10 @@ public class FileUploadAction extends ActionSupport implements UploadedFilesAwar
return originalName;
}
public String getInputName() {
return inputName;
}
public Object getUploadedFile() {
return uploadedFile.getContent();
}
@@ -85,5 +90,6 @@ public class FileUploadAction extends ActionSupport implements UploadedFilesAwar
this.fileName = uploadedFile.getName();
this.contentType = uploadedFile.getContentType();
this.originalName = uploadedFile.getOriginalName();
this.inputName = uploadedFile.getInputName();
}
}
@@ -1,51 +1,52 @@
<!--
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
-->
<%@ page
language="java"
contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
language="java"
contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8" %>
<%@ taglib prefix="s" uri="/struts-tags" %>
<html>
<head>
<title>Struts2 Showcase - Fileupload sample</title>
<title>Struts2 Showcase - Fileupload sample</title>
</head>
<body>
<div class="page-header">
<h1>Fileupload sample</h1>
<h1>Fileupload sample</h1>
</div>
<div class="container-fluid">
<div class="row">
<div class="col-md-12">
<ul>
<li>ContentType: <s:property value="contentType" /></li>
<li>FileName: <s:property value="fileName" /></li>
<li>Original FileName: <s:property value="originalName" /></li>
<li>File: <s:property value="uploadedFile" /></li>
<li>Size: <s:property value="uploadSize" /></li>
<li>Caption: <s:property value="caption" /></li>
</ul>
</div>
</div>
<div class="row">
<div class="col-md-12">
<ul>
<li>ContentType: <s:property value="contentType"/></li>
<li>FileName: <s:property value="fileName"/></li>
<li>Original FileName: <s:property value="originalName"/></li>
<li>File: <s:property value="uploadedFile"/></li>
<li>Caption: <s:property value="caption"/></li>
<li>Size: <s:property value="uploadSize"/></li>
<li>Input name: <s:property value="inputName"/></li>
</ul>
</div>
</div>
</div>
</body>
@@ -59,7 +59,8 @@ public class FileUploadTest {
"ContentType: text/plain",
"Original FileName: " + tempFile.getName(),
"Caption: some caption",
"Size: 12"
"Size: 12",
"Input name: upload"
);
}
}