on a primefaces 3.5 form I created with a datatable the rowKey value is not being returned as a List, therefore I am getting the following error:
JBWEB000309: type JBWEB000066: Exception report
JBWEB000068: message For input string: "foreignPartyId"
JBWEB000069: description JBWEB000145: The server encountered an internal error that prevented it from fulfilling this request.
JBWEB000070: exception
javax.servlet.ServletException: For input string: "foreignPartyId"
javax.faces.webapp.FacesServlet.service(FacesServlet.java:606)
JBWEB000071: root cause
java.lang.NumberFormatException: For input string: "foreignPartyId"
java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
java.lang.Integer.parseInt(Integer.java:492)
java.lang.Integer.parseInt(Integer.java:527)
javax.el.ListELResolver.toInteger(ListELResolver.java:407)
javax.el.ListELResolver.getValue(ListELResolver.java:199)
...
I know the reason is because I am trying to populate the datatable with values from an Object[] array, rather than a List. The Object[] array is actually values from getResultList() using the createNativeQuery method to query an Oracle database.
My question is: How do I convert the values in the Object[] array into a List so that the datatable is populated?
I have tried using the Arrays.toList() method, and then iterating through that adding the values to a list, but I understand that that simply returns a fixed size list of the backed array. It does not return a List of values.
Any help would be greatly appreciated. My apologies if I have not provided enough detail. Thank you.
Try with ArrayList:
ArrayList<Object> list = new ArrayList(Arrays.asList(yourArray));
and then add whatever element you want to the list using
list.add(newItem)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With