Wicket ListView不令人耳目一新

我正在使用Apache Wicket迈出第一步,遇到了以下问题。 我有一个ListView ,在其条目旁边显示“删除”链接。 单击删除链接时,将从数据库中删除列表项所代表的实体,但在我在浏览器中手动重新加载页面之前,列表本身不会更新。 IModel<List> sampleEntityListModel = new LoadableDetachableModel<List>() { @Override protected List load() { return mSampleEntityBA.findAll(); } }; mListview = new ListView(“listview”, sampleEntityListModel) { @Override protected void populateItem(final ListItem item) { item.add(new Label(“listlabel”, new PropertyModel(item.getModelObject(), “text”))); item.add(new Link(“deleteLink”, item.getModel()) { @Override public void onClick() { mSampleEntityBA.delete(item.getModelObject()); } }); } };

如何使用Java编写的程序可用于其他人?

所以我写了一个有趣的小程序,我想把它展示给我的一些朋友。 我的朋友,不是程序员,如果我发送包含必要类和文件的文件夹,他不知道该怎么办。 我希望能够通过电子邮件向他们发送信息(或将其放在CD / thumbdrive上),然后他们可以双击并让它运行程序。 我完全不知道如何实现这一目标。 我正在上课,我们使用Linux计算机(当我不在课堂时使用mac)我们必须javac .java文件然后java“文件名”才能运行。 我在Mac和PC上有朋友,我希望他们只需点击该程序就可以了…. 如果它有所不同,则使用对象绘制库编写程序。

@ManyToMany关系中表的JPA 2.0 CriteriaQuery

我在@ManyToMany关系中有两个实体。 // Output has 4 other @ManyToOne relationships if that matters @Entity @Table public class Output { @Id public String address; @ManyToMany(targetEntity = Interval.class, cascade = CascadeType.ALL, fetch = FetchType.LAZY) @JoinTable(name = “output_has_interval”, joinColumns = {@JoinColumn(name = “output_address”, referencedColumnName = “address”)}, inverseJoinColumns = {@JoinColumn(name = “interval_start”, referencedColumnName = “start”), @JoinColumn(name = “interval_end”, referencedColumnName = “end”)}) […]

GridLayout上的动画精灵

我有点卡住了。 我正在创建一个Java内存游戏,它包含一个6×6网格的动画精灵(我教授的要求)。 在我的试用版中,我只能显示一个具有精灵动画的组件。 我的另一个尝试是改变p1 [i] = new Ash(),它能够将所有精灵绘制到网格中的所有组件但没有动画。 我想问一些关于如何处理这个问题的想法,其中网格中的所有组件都有一个ANIMATED精灵。 我的主要课程: public class Main extends Component{ public static void main(String[] args) { Ash ash = new Ash(); JFrame f = new JFrame(“Game sample”); JPanel panel1 = new JPanel(new GridLayout(6,6,6,6)); JPanel[] p1 = new JPanel[36]; for(int i = 0;i trigger) { trigger = start + delay; ash.repaint(); […]

java.time.format.DateTimeParseException:无法在索引5处解析文本“2016-2-2”

我试图从import java.time.LocalDate;创建一个LocalDate实例import java.time.LocalDate; 我跟着这个 这是我的代码: LocalDate sd= LocalDate.parse(“2016-2-2”); 我遇到了错误: java.time.format.DateTimeParseException: Text ‘2016-2-2’ could not be parsed at index 5 at java.time.format.DateTimeFormatter.parseResolved0(Unknown Source) 在另一个尝试创建LocalDate的实例,我试过 LocalDate ed= new LocalDate(“2016-2-4”); 但它再次抱怨: The constructor LocalDate(String) is undefined

DDD和应用层

应用程序层(应用程序服务)是否在DDD中添加了@ Stateful,@ Stateless,@ WebService等? 从下面的链接看,这似乎是正确的。 第二个问题:我已经创建了一个存储库类,如果所有涉及存储库的方法调用都是在应用程序服务中进行包装吗 或者我可以直接使用存储库类,比如在JSF中支持bean吗? 何时以及我将什么放在应用程序层中。 我不明白EJB在这个艺术中的位置。 应用层:此层协调应用程序活动。 它不包含任何业务逻辑。 它不保存业务对象的状态,但它可以保持应用程序任务的进度状态。 http://www.infoq.com/articles/ddd-in-practice

Java Generic HashMap实现:对象无法转换V

我正在尝试实现一个通用的HashMap,但由于某种原因,java编译器不允许我返回正确的generics类型。 这是我的HashMap代码: public class SimpleHashMap { private int tableSize; private HashEntry[] table; public SimpleHashMap(){ table = new HashEntry[tableSize]; for(int i = 0; i < table.length; i++){ table[i] = null; } } public V put(K key, V value){ int keyIndex = getHashCode(key); if(table[keyIndex] == null){ table[keyIndex] = new HashEntry(key, value); } else{ table[keyIndex] = new HashEntry(key, […]

如何在使用JPA2时对EJB进行unit testing?

您将如何对使用JPA的EJB进行unit testing? 例如,如果我有一个Order实体和OrderEJB,它应该计算一个订单的总数(如下定义),我将如何在不触及数据库的情况下对EJB进行unit testing? 另外,您将如何定义实体的值,以便断言预期的计算? 以下是一些示例代码… @Entity public class Order { @Id private long OrderId; private LineItem[] items; } 和订单EJB @Stateless public class OrderEJB { EntityManager em; public double calculateOrderTotal(long orderId) { .. } } 如果我无法触摸数据库,您将如何进行单位测试calculateOrderTotal方法? 我不想实现DAO,因为我试图摆脱这种方法。 谢谢你的帮助。

如何从base64解码video?

我希望转换video在base64字符串,所以我转换migBase64方法通过我在Android的video它将video转换成字符串成功,但当我解码字符串到video然后它不正确转换video。 如果有人知道,请帮助我。 我尝试如下代码: String encodedString; //Decode Video To String File tempFile = new File(Environment.getExternalStorageDirectory()+ “/my/part/my_0.mp4”); byte fileContent[] = new byte[3000]; try { FileInputStream fin = new FileInputStream(tempFile); while (fin.read(fileContent) >= 0) { // b.append(Base64.encodeToString(fileContent, true)); encodedString = Base64.encodeToString(fileContent, true); } } catch (IOException e) { } //Encoding Video To String Successfully. //Decode String To Video […]

如何使用apache poi为3个单元格设置注释

我想使用Apache POI为3个excel单元格设置注释。 这是我的源代码: import java.io.*; import org.apache.poi.hssf.usermodel.*; import org.apache.poi.hssf.util.HSSFColor; public class CellComments { public static void main(String[] args) throws IOException { HSSFWorkbook wb = new HSSFWorkbook(); HSSFSheet sheet = wb.createSheet(“Cell comments in POI HSSF”); HSSFPatriarch patr = sheet.createDrawingPatriarch(); HSSFCell cell1 = sheet.createRow(3).createCell((short)1); cell1.setCellValue(new HSSFRichTextString(“Hello, World”)); //anchor defines size and position of the comment in worksheet […]