set a breakpoint in
protected boolean isSelected(final Object object, int index, String
selected)
and see why true is not being returned.
-igor
On 4/16/07, V. Jenks <[EMAIL PROTECTED]> wrote:
Yeah, I've tried that also, it just isn't working...no idea why.
Here's what I have, using your suggestion...and I've walked through the
debugger to make sure the date is there, the value is definitely not null.
I must be missing something obvious and simple because it doesn't select
the
correct date:
public class CheckoutPanel extends Panel
{
public CheckoutPanel(String id)
{
super(id);
//get cart from session
final ShoppingCartLocal cart =
((UserSession)getSession()).getCart();
Date arrivalDate = null;
if (cart.getOrder().getEstArrivalDate() != null)
arrivalDate = cart.getOrder().getEstArrivalDate();
CheckoutInput input = new CheckoutInput();
input.setArrivalDate(arrivalDate);
//create form
add(new CheckoutForm("checkoutForm", cart, input));
}
private final class CheckoutForm extends Form
{
private CheckoutForm(String id, final ShoppingCartLocal
cart,
CheckoutInput input)
{
super(id, new CompoundPropertyModel(input));
//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());
}
});
//add dropdown to form
add(arrivalChoices);
}
}
}
ptrthomas wrote:
>
> 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
>
>
--
View this message in context:
http://www.nabble.com/Problem-setting-selected-value-in-DropDownChoice-tf3538227.html#a10017919
Sent from the Wicket - User mailing list archive at Nabble.com.
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Wicket-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/wicket-user
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Wicket-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/wicket-user