Value conflict dropBox
posted 9 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
Hi all,
I have this JSF code:
And this Java one:
This line doesnt match well the required syntax.
What bean represents?
Any iadea, please?
I have this JSF code:
And this Java one:
This line doesnt match well the required syntax.
What bean represents?
Any iadea, please?
posted 9 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
When you select a value from the dropdown list and submit the form, JSF will lookup the object named "bean" and do this or some equivalent:
The value will be the "value" atttribute of the SelectItem object (label/value) corresponding to the selected item.
This means that the method "getStatuses()" for the backing bean named "convert" must have either returned a collection (List or array) of SelectItem's OR that it returns something that JSF (version 2 or higher) can automatically convert into a collection of SelectItem's with a label and value for each SelectItem.
The value will be the "value" atttribute of the SelectItem object (label/value) corresponding to the selected item.
This means that the method "getStatuses()" for the backing bean named "convert" must have either returned a collection (List or array) of SelectItem's OR that it returns something that JSF (version 2 or higher) can automatically convert into a collection of SelectItem's with a label and value for each SelectItem.
Experience keeps a dear School, but Fools will learn in no other.
---
Benjamin Franklin - Postal official and Weather observer
posted 9 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
As there is a fix number of items in the catalog, I am using an enumeration
posted 9 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
I have modified the enum class:
In the .jsp
I am using Servlet for this:
When I run it, I get a white screen with this:
I have added the jar jstl1.2.jar
Any idea, please?
In the .jsp
I am using Servlet for this:
When I run it, I get a white screen with this:
I have added the jar jstl1.2.jar
Any idea, please?
posted 9 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
Don't even think about it.
Despite some questionable examples by Oracle, JSTL is a horrible fit for JSF. There's nothing in JSTL that JSF doesn't have a better version of in its native framework.
JSF has not been very good about handling enums, in my experience. What I recommend it that you build a SelectItem array with one SelectItem per enum value.
I believe you can do this in a generic way by invoking getEnumConstants on the enum class itself, which will return an array of Enum's. Then allocate a corresponding array of SelectItem and populate it by iterating the enum constants array, constructing a SelectItem from its integer value and display name, then adding that SelectItem to the SelectItem array you just built.
Note that this means that your setValue() method will have to accept an argument of type int, which you will then have to translate back into its corresponding enum (the enum having that ordinal value).
Despite some questionable examples by Oracle, JSTL is a horrible fit for JSF. There's nothing in JSTL that JSF doesn't have a better version of in its native framework.
JSF has not been very good about handling enums, in my experience. What I recommend it that you build a SelectItem array with one SelectItem per enum value.
I believe you can do this in a generic way by invoking getEnumConstants on the enum class itself, which will return an array of Enum's. Then allocate a corresponding array of SelectItem and populate it by iterating the enum constants array, constructing a SelectItem from its integer value and display name, then adding that SelectItem to the SelectItem array you just built.
Note that this means that your setValue() method will have to accept an argument of type int, which you will then have to translate back into its corresponding enum (the enum having that ordinal value).
Experience keeps a dear School, but Fools will learn in no other.
---
Benjamin Franklin - Postal official and Weather observer
posted 9 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
Oki later on I will try with JSF now I switch into JSP. So I post this in JSP forum.
| get schwifty. tiny ad: Paul Wheaton's 16th Kickstarter: Gardening playing cards for gardeners and homesteaders https://coderanch.com/t/889615/Paul-Wheaton-Kickstarter-Gardening-playing |








