Note that there are some explanatory texts on larger screens.

plurals
  1. POHow would one optimally use DropDownChoice in Wicket with ChoiceRenderer to handle the display and ID values?
    primarykey
    data
    text
    <p>I am attempting to create a simple dropdown select box in a form with Wicket and am stumped by the exception that Wicket is throwing. As follows:</p> <p><strong>Last cause: No get method defined for class: class java.lang.Long expression: id</strong></p> <p>As I continue to examine the code and the Wicket documentation, I simply cannot figure out what I'm doing wrong and could use the helpful eyes of the Stackoverflow and Wicket community. Here are some relevant code snippets... First, my form which uses a CompoundPropertyModel:</p> <pre><code>add(jobForm); // Unrelated fields snipped, see 'employmentTypeId': jobForm.setModel(new CompoundPropertyModel&lt;Job&gt;(jobModel)); jobForm.add(new DropDownChoice("employmentTypeId", new List&lt;GenericPickList&gt;, new ChoiceRenderer&lt;GenericPickList&gt;("description", "id"))); </code></pre> <p>The arguments in the DropDownChoice explained: #1, the wicket:id of the component, #2, in the actual implementation, this is a fully populated List collection of GenericPickList (i.e. List), #3, my ChoiceRenderer that identifies the description field as the display value and the id value as the ID, both from a GenericPickList class.</p> <p>The GenericPickList class is simple:</p> <pre><code>public class GenericPickList { private long id; private String description; public long getId() { return id; } public void setId(long id) { this.id = id; } public String getDescription() { return description; } public void setDescription(String description) { this.description = description; } } </code></pre> <p>The error suggests that the ChoiceRenderer is not finding the getter for the id field in GenericPickList, but it's there so I'm led to believe my assumptions are incorrect. Can anyone offer any insight with this?</p> <p>As an added note (and point of frustration), it appears to work fine with the "id" is removed from the ChoiceRenderer constructor:</p> <pre><code>new ChoiceRenderer&lt;GenericPickList&gt;("description"); </code></pre> <p>Of course, since these are data driven values with primary keys associated, the inclusion of the ID value is required for my purposes.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload