Posts by Henrique Luiz • 447 points
26 posts
-
1
votes2
answers250
viewsQ: How to validate elements produced during a Java Stream before Collect?
Given the hypothetical example below as it would be the best way to validate all the elements produced by a Java Stream, in the example below I would like to check if all the elements produced are…
-
0
votes1
answer81
viewsA: Error trying to change Javafx application icon
It’s been a while since I used Javafx, but from what I’m seeing the problem is in the image path, "src/Icons/message.png" It is looking for the src/Icons folder from the relative class path try…
-
-1
votes1
answer345
viewsA: Java - Change XML and then read
Probably your main problem is that a reading application is reading the file at the same time as the writing one is writing, it may result in org.jdom2.input.Jdomparseexception. Try to put your code…
-
0
votes1
answer463
viewsA: using Entitymanager to return a List
With JPQL the Query are made in the OO style, its error is put and.cpfProprietary being that the Telephone class does not have a property called cpfProprietary but rather a proprietary that contains…
-
1
votes1
answer524
viewsA: E-mail with Javamail copy
Use the addBcc() method for hidden copying and addcc() for copying follows the reference below. BCC:…
-
1
votes1
answer74
viewsA: Access a method that is outside the thread
To have access to the UI you must ask the UI API to run a certain code in the UI thread, in the case of Javafx follow the excerpt below. Platform.runLater(new Runnable() { @Override public void…
-
0
votes1
answer599
viewsA: How do I make a method in the Spring controller that does the same as this method of a Servlet?
Tend to feel the example below. @RestController @RequestMapping(value = "/student") public class StudentJsonData { @RequestMapping(value = "/jsonData", method = RequestMethod.GET,…
-
1
votes1
answer280
viewsA: putExtra in Spinner
You can save the Activit state by overriding the onSaveInstanceState() method and restoring with the onRestoreInstanceState method(). It would look something like this. void onSaveInstanceState…
androidanswered Henrique Luiz 447 -
2
votes1
answer405
viewsA: Testing Factory Hibernate
The way you are using Hibernateutil.getFactory() will return null, try starting the Factory variable in the getFactory method(). package util; import org.hibernate.SessionFactory; import…
-
0
votes1
answer295
viewsA: Why is it mandatory to initialize a final variable when an instance is built?
Simply the final variable modifier serves to make it immutable, so in order for it to be immutable it must have its value initialized in the command in which it is declared or in the class…
javaanswered Henrique Luiz 447 -
0
votes1
answer315
viewsA: Load a Listview into a Fragment from a Fragment
There are Libs for this work but at the moment I do not remember the names, other two forms are with Intents is Intents Filters or the simplest way I will exemplify below. In the Cartfragment class…
-
1
votes3
answers1428
viewsA: How to define the comparison of equality between two objects present in an Arraylist?
First you should understand how java compares narrowly two variables. For primitive type variables such as short, int, float, double, long, char, byte (Basically all types starting with minuscule…
-
0
votes1
answer111
viewsA: How to reconcile good Object Orientation practices and ORM frameworks for getters and setters?
If I’m not mistaken in the case of @id it ignores the get/set methods unless you put @id on get, but there is the @Access annotation that configures whether you ORM will access via Field or…
-
3
votes3
answers1598
viewsA: Hibernate vs Eclipselink
yes there is difference in behavior between the two, but only where the specification does not make clear what should be done, follow the links for more information.…
-
1
votes2
answers86
viewsA: Capture list item by index
For your case the best would be an if before the minhalista.get(i + x); for(int i = 0; i < 99999; i++) { if((i + x) < minhaLista.size()){ minhaLista.get(i + x); //x é int e possui um valor…
-
0
votes1
answer242
viewsA: I am trying to add a Listview inside a Viewpager Ragment and returns me the following error. Any suggestions?
I haven’t examined your code very well, but it’s very likely to be in the line below. ArrayAdapter<String> arrayAdapter = new…
-
1
votes3
answers400
viewsA: Make a Static method in the main class that writes on the screen all even numbers from 1 to 10000 that are palindromes
The problem is in these two lines; for(int i=0;i<=vet.length;i++) for (int i = 0; i <= vet2.length; i++) The length property returns the total size of elements in the array, so when using to…
-
0
votes1
answer607
viewsA: How to create a Listview in a Navigation Drawer?
I think the code below can solve your problem. Menu menu = navigationView.getMenu(); for (String itemMenu : menus) { MenuItem menuItem = menu.add(itemMenu); menuItem.setIcon(....);…
-
0
votes1
answer159
viewsA: Load image after selected item
You can create a Servlet that reads the image file in a directory according to a parameter in the url and then pass as parameter in the graphicImage url; urlImagem = "/imagem?nome=nome-da-imagem";…
-
1
votes1
answer32
viewsA: Booleanbinding of multiple properties
There is no way to do this since the object has several properties that can be linked, so A.bindBidirectional(B.bindBidirectional(C)) the class would not know which attribute it should link to. But…
-
0
votes1
answer216
viewsA: How to validate attributes in Spring Batch
You can use the Validation Bean following the example: Class with the annotations: public class Cliente { @NotNull("O nome é obrigatorio") @Size(min = 3, max = 20) private String nome; @NotNull("O…
-
1
votes2
answers224
viewsA: Setup pointcut AOP Spring
Based on Anthony Accioly’s answer I’ve come up with a solution. Annotation: @Retention(RetentionPolicy.RUNTIME) public @interface NoTransactional { } Declaration class of pointcuts: @Aspect public…
-
2
votes2
answers224
viewsQ: Setup pointcut AOP Spring
I have the below pointcut setting on Spring 3 <aop:config> <aop:pointcut id="baseDaoPointcut" expression="execution(* br.com.infraestrutura.domain.BaseDao+.*(..))" /> <aop:pointcut…
-
1
votes1
answer70
viewsA: No string in an array with Bufferedreader
Use the equals method to compare these objects. Your method would look like this. public int getIDCidade(T cidade) { int id = -1; String cidadec = (String) cidade; for (int i = 0; i <…
javaanswered Henrique Luiz 447 -
0
votes1
answer199
viewsA: How to work with Threads without crashing the GUI
Change Thread t2 = new Thread(new VerificaTerminal()); t2.start(); by no Swing SwingUtilities.invokeLater(new VerificaTerminal()); or in Javafx Platform.runLater(new VerificaTerminal())…
-
4
votes0
answers53
viewsQ: What is the advantage of using OSGI?
What is the advantage of using the OSGI to separate the modules from the project? What would transactions look like in transactions between modules, and relationships between different module…