- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我的项目是使用 Eclipse Juno 的 GWT Java。
我正在使用 GWTUpload,但是选择图片后,不显示文件路径和文件名。如何在选择图片后在“浏览”按钮之前显示文件路径和名称?
package org.AwardTracker.client;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.FlowPanel;
import com.google.gwt.user.client.ui.VerticalPanel;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.FlexTable;
import com.google.gwt.user.client.ui.TextBox;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.core.client.GWT;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.rpc.ServiceDefTarget;
import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.user.client.ui.Image;
import com.google.gwt.user.client.ui.HasHorizontalAlignment;
import com.google.gwt.user.client.ui.ListBox;
import com.google.gwt.i18n.client.DateTimeFormat;
import gwtupload.client.IUploadStatus.Status;
import gwtupload.client.IUploader;
import gwtupload.client.IUploader.UploadedInfo;
import gwtupload.client.MultiUploader;
import gwtupload.client.PreloadedImage;
import gwtupload.client.PreloadedImage.OnLoadPreloadedImageHandler;
import java.io.File;
import java.lang.String;
import java.sql.Date;
import java.util.List;
import com.google.gwt.user.client.ui.FileUpload;
import com.google.gwt.user.datepicker.client.DateBox;
import com.google.gwt.user.datepicker.client.DateBox.DefaultFormat;
public class EditYouthMemberView extends Composite {
private DBConnectionAsync rpc;
private TextBox textBoxFirstName;
private TextBox textBoxScoutNumber;
private ListBox listBoxSection;
private ListBox listBoxPack;
private TextBox textBoxSurname;
private DateBox dateBoxArchived;
private DateBox dateBoxPackIn;
private DateBox dateBoxPackOut;
private DateBox dateBoxDOB;
// A panel where the thumbnails of upload images will be shown
//final FlowPanel panelImages = new FlowPanel();
final HorizontalPanel panelImages = new HorizontalPanel();
@SuppressWarnings("deprecation")
public EditYouthMemberView(final NavHandler navHandler) {
final java.util.Date todays_date = new java.util.Date();
rpc = (DBConnectionAsync) GWT.create(DBConnection.class);
ServiceDefTarget target = (ServiceDefTarget) rpc;
String moduleRelativeURL = GWT.getModuleBaseURL() + "MySQLConnection";
target.setServiceEntryPoint(moduleRelativeURL);
VerticalPanel verticalPanel = new VerticalPanel();
verticalPanel.setStyleName("gwt-Banner");
initWidget(verticalPanel);
HorizontalPanel horizontalPanel = new HorizontalPanel();
horizontalPanel.setStyleName("gwt-Banner");
verticalPanel.add(horizontalPanel);
horizontalPanel.setWidth("246px");
Label lblHome = new Label("Home");
lblHome.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
}
});
horizontalPanel.add(lblHome);
lblHome.setWidth("46px");
Label lblEditAwards = new Label("Edit Awards");
lblEditAwards.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
}
});
horizontalPanel.add(lblEditAwards);
lblEditAwards.setWidth("85px");
Label lblListAll = new Label("List all Cub Scouts");
lblListAll.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
}
});
horizontalPanel.add(lblListAll);
lblListAll.setWidth("130px");
Label lblAccountUpdate = new Label("Account Update");
lblAccountUpdate.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
}
});
horizontalPanel.add(lblAccountUpdate);
lblAccountUpdate.setWidth("104px");
FlexTable flexTable_1 = new FlexTable();
verticalPanel.add(flexTable_1);
Label lblSurname = new Label("Surname");
lblSurname.setWordWrap(false);
lblSurname.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT);
lblSurname.setStyleName("gwt-Label-Login");
flexTable_1.setWidget(0, 2, lblSurname);
Label lblFirstName = new Label("First Name");
lblFirstName.setWordWrap(false);
lblFirstName.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT);
lblFirstName.setStyleName("gwt-Label-Login");
flexTable_1.setWidget(0, 3, lblFirstName);
textBoxSurname = new TextBox();
flexTable_1.setWidget(1, 1, textBoxSurname);
textBoxFirstName = new TextBox();
flexTable_1.setWidget(1, 2, textBoxFirstName);
Label lblLookForPhotograph = new Label("Look for photograph:");
lblLookForPhotograph.setWordWrap(false);
lblLookForPhotograph.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT);
lblLookForPhotograph.setStyleName("gwt-Label-Login");
flexTable_1.setWidget(2, 1, lblLookForPhotograph);
flexTable_1.getFlexCellFormatter().setRowSpan(2, 1, 3);
// Attach the image viewer to the document
flexTable_1.setWidget(0, 0, panelImages);
panelImages.setSize("120", "120");
flexTable_1.getFlexCellFormatter().setRowSpan(0, 0, 4);
panelImages.clear();
// Create a new uploader panel and attach it to a document
final MultiUploader defaultUploader = new MultiUploader();
flexTable_1.setWidget(3, 1, defaultUploader);
flexTable_1.getFlexCellFormatter().setRowSpan(3, 1, 3);
// Add a finish handler which will load the image once the upload finishes
defaultUploader.addOnFinishUploadHandler(onFinishUploaderHandler);
FlexTable flexTable = new FlexTable();
verticalPanel.add(flexTable);
Label lblDOB = new Label("Date of Birth:");
lblDOB.setWordWrap(false);
lblDOB.setStyleName("gwt-Label-Login");
flexTable.setWidget(0, 0, lblDOB);
lblDOB.setDirectionEstimator(false);
lblDOB.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_RIGHT);
lblDOB.setSize("110px", "16px");
dateBoxDOB = new DateBox();
dateBoxDOB.setFormat(new DefaultFormat(DateTimeFormat.getFormat("dd-MM-yyyy")));
flexTable.setWidget(0, 1, dateBoxDOB);
dateBoxDOB.getDatePicker();
Label lblSection = new Label("Section:");
lblSection.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_RIGHT);
lblSection.setStyleName("gwt-Label-Login");
flexTable.setWidget(0, 2, lblSection);
listBoxSection = new ListBox();
listBoxSection.addItem("Cubs");
flexTable.setWidget(0, 3, listBoxSection);
listBoxSection.setVisibleItemCount(1);
Label lblScoutNumber = new Label("Scout Number:");
lblScoutNumber.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_RIGHT);
lblScoutNumber.setStyleName("gwt-Label-Login");
flexTable.setWidget(1, 0, lblScoutNumber);
lblScoutNumber.setDirectionEstimator(false);
lblScoutNumber.setSize("110px", "16px");
textBoxScoutNumber = new TextBox();
flexTable.setWidget(1, 1, textBoxScoutNumber);
Label lblPack = new Label("Pack:");
lblPack.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_RIGHT);
lblPack.setStyleName("gwt-Label-Login");
flexTable.setWidget(1, 2, lblPack);
listBoxPack = new ListBox();
listBoxPack.addItem("Explorer");
listBoxPack.addItem("Pioneer");
flexTable.setWidget(1, 3, listBoxPack);
listBoxPack.setVisibleItemCount(1);
Label lblDateArchived = new Label("Date Archived:");
lblDateArchived.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_RIGHT);
lblDateArchived.setStyleName("gwt-Label-Login");
flexTable.setWidget(2, 0, lblDateArchived);
lblDateArchived.setSize("110px", "16px");
dateBoxArchived = new DateBox();
dateBoxArchived.setFormat(new DefaultFormat(DateTimeFormat.getFormat("dd-MM-yyyy")));
flexTable.setWidget(2, 1, dateBoxArchived);
dateBoxArchived.getDatePicker();
Label lblIn_1 = new Label("In:");
lblIn_1.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_RIGHT);
lblIn_1.setStyleName("gwt-Label-Login");
flexTable.setWidget(2, 2, lblIn_1);
dateBoxPackIn = new DateBox();
dateBoxPackIn.setFormat(new DefaultFormat(DateTimeFormat.getFullDateFormat()));
flexTable.setWidget(2, 3, dateBoxPackIn);
dateBoxPackIn.getDatePicker();
Label lblNewLabel_3 = new Label("Out:");
lblNewLabel_3.setStyleName("gwt-Label-Login");
flexTable.setWidget(2, 4, lblNewLabel_3);
dateBoxPackOut = new DateBox();
dateBoxPackOut.setFormat(new DefaultFormat(DateTimeFormat.getFormat("dd-MM-yyyy")));
dateBoxPackOut.getDatePicker();
flexTable.setWidget(2, 5, dateBoxPackOut);
Button btnAdd = new Button("Add");
btnAdd.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
Integer tracker = 0;
if (textBoxSurname.getText().length() == 0) {
tracker = tracker + 1;
}
if (textBoxFirstName.getText().length() == 0) {
tracker = tracker + 2;
}
// if (panelImages.getFilename().length() == 0) {
// tracker = tracker + 4;
// }
if (dateBoxDOB.toString().length() == 0) {
tracker = tracker + 8;
}
if (dateBoxPackIn.toString().length() == 0) {
tracker = tracker + 16;
}
if (tracker == 1) {
Window.alert("Please enter a Surname.");
}
if (tracker == 2) {
Window.alert("Please enter a First Name.");
}
if (tracker == 3) {
Window.alert("Please enter Surname and First Name");
}
if (tracker == 4) {
Window.alert("Please select a photograph.");
}
if (tracker == 5) {
Window.alert("Please enter a Surname and select a photograph.");
}
if (tracker == 6) {
Window.alert("Please enter a FirstName and select a photograph.");
}
if (tracker == 7) {
Window.alert("Please enter Surname, First Name and select a photograph");
}
if (tracker == 8) {
Window.alert("Please enter a DOB");
}
if (tracker == 9) {
Window.alert("Please enter a Surname and DOB");
}
if (tracker == 10) {
Window.alert("Please enter a First Name and DOB");
}
if (tracker == 11) {
Window.alert("Please enter a Surname, First Name and DOB");
}
if (tracker == 12) {
Window.alert("Please select a photograph and enter a BOB");
}
if (tracker == 13) {
Window.alert("Please enter a Surname, select a photograph and enter a DOB");
}
if (tracker == 14) {
Window.alert("Please enter a FirstName, select a photograph and enter a DOB");
}
if (tracker == 15) {
Window.alert("Please enter Surname, First Name, select a photograph and enter a DOB");
}
if (tracker == 16) {
Window.alert("Please enter date joined Pack");
}
if (tracker == 17) {
Window.alert("Please enter a Surname and date joined Pack.");
}
if (tracker == 18) {
Window.alert("Please enter a First Name and date joined Pack.");
}
if (tracker == 19) {
Window.alert("Please enter Surname, First Name and date joined Pack");
}
if (tracker == 20) {
Window.alert("Please select a photograph and enter date joined Pack.");
}
if (tracker == 21) {
Window.alert("Please enter a Surname, select a photograph and enter date joined Pack.");
}
if (tracker == 22) {
Window.alert("Please enter a First Name, select a photograph and enter date joined Pack.");
}
if (tracker == 23) {
Window.alert("Please enter Surname, First Name, select a photograph and enter date joined Pack");
}
if (tracker == 24) {
Window.alert("Please enter a DOB and date joined Pack");
}
if (tracker == 25) {
Window.alert("Please enter a Surname, DOB and date joined Pack");
}
if (tracker == 26) {
Window.alert("Please enter a First Name, DOB and date joined Pack");
}
if (tracker == 27) {
Window.alert("Please enter a Surname, First Name, DOB and date joined Pack");
}
if (tracker == 28) {
Window.alert("Please select a photograph, enter a BOB and date joined Pack");
}
if (tracker == 29) {
Window.alert("Please enter a Surname, select a photograph, enter a DOB and date joined Pack");
}
if (tracker == 30) {
Window.alert("Please enter a FirstName, select a photograph, enter a DOB and date joined Pack");
}
if (tracker == 31) {
Window.alert("Please enter Surname, First Name, select a photograph, enter a DOB and date joined Pack");
}
//if (tracker == 0) {
// AsyncCallback<YthMmbrSectDtls> callback = new CreationHandler<YthMmbrSectDtls>(null);
// rpc.createYouthMember(null, textBoxSurname.getText(), textBoxFirstName.getText(), dateBoxDOB.getValue(),
// fileUpload.getFilename(), dateBoxArchived.getValue(), null, listBoxSection.getItemText(listBoxSection.getSelectedIndex()),
// listBoxPack.getItemText(listBoxPack.getSelectedIndex()), dateBoxPackIn.getValue(),
// dateBoxPackOut.getValue(), callback);
//}
}
});
flexTable.setWidget(3, 0, btnAdd);
Button btnUpdate = new Button("Update");
btnUpdate.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
}
});
btnUpdate.setText("Update");
flexTable.setWidget(3, 1, btnUpdate);
Button btnCancel = new Button("Cancel");
btnCancel.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
}
});
btnCancel.setText("Cancel");
flexTable.setWidget(3, 2, btnCancel);
Button btnClearPage = new Button("Clear Page");
btnClearPage.setText("Clear Page");
btnClearPage.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
textBoxSurname.setText("");
textBoxFirstName.setText("");
dateBoxDOB.setValue(null);
dateBoxPackIn.setValue(todays_date);
dateBoxPackOut.setValue(null);
textBoxScoutNumber.setText("");
dateBoxArchived.setValue(null);
}
});
flexTable.setWidget(3, 3, btnClearPage);
setStyleName("body");
}
// Load the image in the document and in the case of success attach it to the viewer
private IUploader.OnFinishUploaderHandler onFinishUploaderHandler = new IUploader.OnFinishUploaderHandler() {
public void onFinish(IUploader uploader) {
if (uploader.getStatus() == Status.SUCCESS) {
new PreloadedImage(uploader.fileUrl(), showImage);
//The server sends useful information to the client by default
UploadedInfo info = uploader.getServerInfo();
System.out.println("File name " + info.name);
System.out.println("File content-type " + info.ctype);
System.out.println("File size " + info.size);
// You can send any customised message and parse it
System.out.println("Server message " + info.message);
}
}
};
// Attach an image to the pictures viewer
private OnLoadPreloadedImageHandler showImage = new OnLoadPreloadedImageHandler() {
public void onLoad(PreloadedImage image) {
image.setWidth("75px");
panelImages.add(image);
}
};
/**
* Decodes the base64 string into byte array to display image
* Calls Base64Decode.java
* @param imageDataString - a {@link java.lang.String}
* @return byte array
*/
public static byte[] decodeImage(String imageDataString) {
return Base64Decode.decode(imageDataString);
}
public IUploader.OnFinishUploaderHandler getOnFinishUploaderHandler() {
return onFinishUploaderHandler;
}
public void setOnFinishUploaderHandler(IUploader.OnFinishUploaderHandler onFinishUploaderHandler) {
this.onFinishUploaderHandler = onFinishUploaderHandler;
}
}
事情是这样的:我选择照片的开始屏幕
我选择一张照片,它会自动开始加载。加载时可以看到路径
照片完成后,自动显示的文件路径就会消失。
最佳答案
MultiUploader 监听底层输入元素上的更改事件,并自动将所选文件上传到服务器。然后它会创建一个新表单,以便可以选择更多文件。因此,您永远无法看到“浏览”按钮旁边的位置/名称。
看起来您只想选择一个文件(如果我正确地阅读了您的代码),您可能会考虑使用 IUploader 的不同实现,例如 gwtupload.client.SingleUploader
。
关于java - GWTUpload 不显示文件路径,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17007449/
我正在编写一个具有以下签名的 Java 方法。 void Logger(Method method, Object[] args); 如果一个方法(例如 ABC() )调用此方法 Logger,它应该
我是 Java 新手。 我的问题是我的 Java 程序找不到我试图用作的图像文件一个 JButton。 (目前这段代码什么也没做,因为我只是得到了想要的外观第一的)。这是我的主课 代码: packag
好的,今天我在接受采访,我已经编写 Java 代码多年了。采访中说“Java 垃圾收集是一个棘手的问题,我有几个 friend 一直在努力弄清楚。你在这方面做得怎么样?”。她是想骗我吗?还是我的一生都
我的 friend 给了我一个谜语让我解开。它是这样的: There are 100 people. Each one of them, in his turn, does the following
如果我将使用 Java 5 代码的应用程序编译成字节码,生成的 .class 文件是否能够在 Java 1.4 下运行? 如果后者可以工作并且我正在尝试在我的 Java 1.4 应用程序中使用 Jav
有关于why Java doesn't support unsigned types的问题以及一些关于处理无符号类型的问题。我做了一些搜索,似乎 Scala 也不支持无符号数据类型。限制是Java和S
我只是想知道在一个 java 版本中生成的字节码是否可以在其他 java 版本上运行 最佳答案 通常,字节码无需修改即可在 较新 版本的 Java 上运行。它不会在旧版本上运行,除非您使用特殊参数 (
我有一个关于在命令提示符下执行 java 程序的基本问题。 在某些机器上我们需要指定 -cp 。 (类路径)同时执行java程序 (test为java文件名与.class文件存在于同一目录下) jav
我已经阅读 StackOverflow 有一段时间了,现在我才鼓起勇气提出问题。我今年 20 岁,目前在我的家乡(罗马尼亚克卢日-纳波卡)就读 IT 大学。足以介绍:D。 基本上,我有一家提供簿记应用
我有 public JSONObject parseXML(String xml) { JSONObject jsonObject = XML.toJSONObject(xml); r
我已经在 Java 中实现了带有动态类型的简单解释语言。不幸的是我遇到了以下问题。测试时如下代码: def main() { def ks = Map[[1, 2]].keySet()
一直提示输入 1 到 10 的数字 - 结果应将 st、rd、th 和 nd 添加到数字中。编写一个程序,提示用户输入 1 到 10 之间的任意整数,然后以序数形式显示该整数并附加后缀。 public
我有这个 DownloadFile.java 并按预期下载该文件: import java.io.*; import java.net.URL; public class DownloadFile {
我想在 GUI 上添加延迟。我放置了 2 个 for 循环,然后重新绘制了一个标签,但这 2 个 for 循环一个接一个地执行,并且标签被重新绘制到最后一个。 我能做什么? for(int i=0;
我正在对对象 Student 的列表项进行一些测试,但是我更喜欢在 java 类对象中创建硬编码列表,然后从那里提取数据,而不是连接到数据库并在结果集中选择记录。然而,自从我这样做以来已经很长时间了,
我知道对象创建分为三个部分: 声明 实例化 初始化 classA{} classB extends classA{} classA obj = new classB(1,1); 实例化 它必须使用
我有兴趣使用 GPRS 构建车辆跟踪系统。但是,我有一些问题要问以前做过此操作的人: GPRS 是最好的技术吗?人们意识到任何问题吗? 我计划使用 Java/Java EE - 有更好的技术吗? 如果
我可以通过递归方法反转数组,例如:数组={1,2,3,4,5} 数组结果={5,4,3,2,1}但我的结果是相同的数组,我不知道为什么,请帮助我。 public class Recursion { p
有这样的标准方式吗? 包括 Java源代码-测试代码- Ant 或 Maven联合单元持续集成(可能是巡航控制)ClearCase 版本控制工具部署到应用服务器 最后我希望有一个自动构建和集成环境。
我什至不知道这是否可能,我非常怀疑它是否可能,但如果可以,您能告诉我怎么做吗?我只是想知道如何从打印机打印一些文本。 有什么想法吗? 最佳答案 这里有更简单的事情。 import javax.swin
我是一名优秀的程序员,十分优秀!