Posts

Showing posts from October, 2016

When to set UI Component private / public in Javafx :

- If you write  UI component in private controller class then it is mandetory to write annotation for Example - @FXML                        Private TextFiled textFiled; If you declare UI component as public then there is no need to write annotation for Example : public TextFiled textFiled; Better practice is to Write annotation and keep all UI component private in Controller class. 

Java: Best way to iterate through an Collection

Some times there is possibility to get concurrent modification exception while retrieving element from collection. Example : On any collection object say Array List , you are adding and removing data sententiously for refesh ui  purpose , then in this case if you are iterating collection object by simple for loop or foreach loop then there is possibility to get  ConcurrentModificationException So use iterator to fetch element from collection. For more details please read internal working of  iterator.

JAVAFX - UI-UNRESPONSIVE FOR LONG RUNNING PROCESS

Scene is not a thread safe and can only be accessed and modified from the UI thread also known as the JavaFX Application thread. Long-running tasks on the JavaFX Application thread makes an application UI unresponsive. The Java platform provides a complete set of concurrency libraries available through the java.util.concurrent package. . The javafx.concurrent package consists of the Worker interface and two basic classes, Task and Service, both of which implement the Worker interface . . Solution :  Create task and write logic in it .   Task<Void> task = new Task<Void>() {             public Void call() { // write your logic here               return null;             }           };           task.setOnSucceeded(event -> {           });

How to update war content without extracting /unpacking

private static void updateIBPublicationBuilderWar(String installationPath) throws IOException {     String warFilePath = "orignal war file"; // ex test.war     String tempWarFilePath = "temp war file name" ; // temp.war     File warFile = new File(warFilePath);     File tempWarFile = new File(tempWarFilePath);     ZipFile zipFile = new ZipFile(warFile);     FileOutputStream fos = new FileOutputStream(tempWarFile);     ZipOutputStream zipOutputStream = new ZipOutputStream(fos);     for (Enumeration enumeration = zipFile.entries(); enumeration.hasMoreElements();) {       ZipEntry zipEntry = (ZipEntry) enumeration.nextElement();       if (!zipEntry.getName().equalsIgnoreCase("WEB-INF/classes/ibserver.properties")) {         zipOutputStream.putNextEntry(zipEntry);         InputStream inputStream = zipFile.getInputStream(zipEntry);         byte[] buf = new byte[1024];         int len;         while ((len = inputStream.read(buf)) > 0) {