I don't see a reason why this shouldn't work.
Please create a quickstart showing the problem.
Sven
On 02/06/2014 10:47 AM, MissOvenMitts wrote:
Hi guys!
I'm using a ChoiceRenderer for the first time, and am having a slight
problem with it. Any help would be *greatly* appreciated!
I have a DropDownChoice used to select a particular PeriodBean object which
uses a ChoiceRenderer to properly display only the "Description" string of
the object. The issue is that once a selection is made and I submit the form
(works properly), the DropDownChoice goes back to not having a selection
displayed (because, I'm assuming, it doesn't know how to take the item in
the property model and display it in the DropDownChoice). How do I make it
continue to properly display the selected PeriodBean Description?
Here's code (simplified version of mine):
// This is what a PeriodBean looks like:
public class PeriodBean implements Serializable {
private String periodIndex;
private String periodDescription;
public String getPeriodIndex() {
return periodIndex;
}
public void setPeriodIndex(String periodIndex) {
this.periodIndex = periodIndex;
}
public String getPeriodDescription() {
return periodDescription;
}
public void setPeriodDescription(String periodDescription) {
this.periodDescription = periodDescription;
}
}
// This is what my SearchCriteriaBean looks like (stores the selected value
from the dropdown):
public class SearchCriteriaBean implements Serializable {
private PeriodBean selectedPeriod;
public PeriodBean getSelectedPeriod() {
return performancePeriod;
}
public void setSelectedPeriod(PeriodBean periodBean ) {
this.selectedPeriod= periodBean;
}
}
// This is a PeriodList item that creates the list of acceptable choices for
my dropdown
public class PeriodList extends
AbstractReadOnlyModel<List<? extends PeriodBean>> {
public PeriodList() {
super();
}
@Override
public List<PeriodBean> getObject() {
List<PeriodBean> pendings = new ArrayList<PeriodBean>();
// Go to the database and do some stuff to get the proper list of
selectable pending periods
return pendingPeriods;
}
public Iterator<PeriodBean> iterator() {
List<PeriodBean> pendings = this.getObject();
return pendings.iterator();
}
};
// And this is JAVA in the Page itself:
// Create a search criteria
SearchCriteriaBean searchCriteria = new SearchCriteriaBean(); //Defined
above
// Create a list
PeriodList periodChoices = new PeriodList(); //Defined above
// Create my dropdown and choice renderer to display the period description
ChoiceRenderer<PeriodBean> choiceRenderer = new ChoiceRenderer<PeriodBean>(
"periodDescription", "periodIndex");
DropDownChoice<PeriodBean> periodChoice = new DropDownChoice<PeriodBean>(
"periodChoice",
new PropertyModel<PeriodBean>(searchCriteria, "selectedPeriod"),
periodChoices, choiceRenderer);
periodChoice.setOutputMarkupId(true);
periodChoice.setRequired(true);
form.add(periodChoice); // There is a form on this page but I am not showing
for simplicity.
--
View this message in context:
http://apache-wicket.1842946.n4.nabble.com/Choice-Renderers-Display-Issue-After-Submit-tp4664225.html
Sent from the Users forum mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org