Instead of pre-loading in the input field, try pre-loading the property in
your form backing object (model) - so call setArrivalDate() or just ensure
that PaymentInfoInput.arrivalDate is not null
On 4/7/07, V. Jenks <[EMAIL PROTECTED]> wrote:
I feel like I've asked this question before...but here I am again. I'm
simply trying to set a selected value for a DropDownChoice when a page is
loaded.
I've tried pre-loading it into the input class, setting it in
getDefaultChoice, and also by trying to pass a model into the control w/
the
value in the getObject method. I'm sure it's a simple thing but the
DropDownChoice is tricky at times...for me anyhow.
Here's my control:
//get calendar days (buffer by 2 days & go 1 month
ahead)
List<String> days = DateTime.getDaysListForward(2,
1, true);
//create dropdown w/ days List
DropDownChoice arrivalChoices = new
DropDownChoice("arrivalDate", days)
{
protected String getDefaultChoice(final
Object selected)
{
return ""; //get rid of "Choose
One" default
}
};
//override key/value in dropdown
arrivalChoices.setChoiceRenderer(new
IChoiceRenderer()
{
public String getIdValue(Object object,
int index)
{
return object.toString();
}
public String getDisplayValue(Object
object)
{
//format differently for display,
i.e. "Thu, Mar 2"
return
DateTime.getCartDateFormatString(object.toString());
}
});
It simply loads a list of strings that are converted dates, they look like
"Fri, Mar 6", "Sat, Mar 7", etc.
The form input class looks like this:
public class PaymentInfoInput implements Serializable
{
private int expiryMonth;
private int expiryYear;
private String number;
private String securityCode;
private String giftMessage;
private String arrivalDate;
.....................
}
I tried pre-loading the arrivalDate into the input before passing it into
the form like so:
................................
PaymentInfoInput input = new PaymentInfoInput();
input.setArrivalDate(
DateTime.getCartDateFormatString (
order.getEstArrivalDate().toString()));
add(new PaymentInfoForm("paymentInfoForm", input));
...............................
...but it doesn't seem to work.
How can I make this item selected in the dropdown list when the page
loads?
--
View this message in context:
http://www.nabble.com/Problem-setting-selected-value-in-DropDownChoice-tf3538227.html#a9876678
Sent from the Wicket - User mailing list archive at Nabble.com.
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share
your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Wicket-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/wicket-user
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Wicket-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/wicket-user