Re: DropDownChoice - how to get the current selected value and I can't use OnSelected event as well :(

2007-10-15 Thread Nino Saturnino Martinez Vazquez Wael

Hi Ray

@1 This is a typical newcommer question, I asked it myself once:). I 
think you should check here:

http://cwiki.apache.org/WICKET/working-with-wicket-models.html

Basic is that you create a dropdownchoice, and pass a model to it( a 
model are something that encapsulates your selected object). Then wicket 
will automaticly put the selected object into the model, and if you 
provide a model that already contain something wicket will automaticly 
select it in the dropdown (providing that you supplied it with a list 
that contains that object). If you need special rendering create your 
own Ichoicerenderer, you will get the current object, return what you 
want from the object to be displayed(eg from person you might return 
person.getName()). I've been told that the ID part you can get away with 
just returning the id again.


@2
You can use the latter approach overiding the protected method, but 
remember that it goes in conjunction with 
wantOnSelectionNotificationChanges or something like that must be 
overriden aswell returning true.


BTW: say if you need more information.

regards Nino

raybristol wrote:

Hi, I am quite new to wicket and got 2 questions about DropDownChoice don't
know how to solve even after some googling as well from this forum so need
some helps again:

1. I want to get the current selected item's value from DropDownChoice, I
was looking for something like 


DropDownChoiceObject.selectedValueOrID() - something equitvalent, I saw the
example from wicket website, it's using:

DropDownChoice ddc = 
new DropDownChoice("name", 
new PropertyModel(employee, "managedBy"),

new LoadableDetachableModel() {
   ...
}
);

so do I have to pass in a PropertyModel to achieve what I want? mine is:

	final Map choiceMap = new HashMap(); 
	final List jpNameString = new ArrayList();

for (JobProfile j : jobProfiles){
choiceMap.put(String.valueOf(j.getId()), j.getName());
jpNameString.add(String.valueOf(j.getId()));
}
IChoiceRenderer renderer = new ChoiceRenderer() {
public Object getDisplayValue(Object object) {
return choiceMap.get(object);}
		public String getIdValue(Object object, int index) { 
return object.toString(); 
} 


};
	
	final DropDownChoice ddc = new DropDownChoice(

"filterByJobProfileName", jpNameString, renderer)


2. my second question is how to use event OnSelectionChange, I saw two
events from the API, one is final so I can't overide, one is pretected:

final void onSelectionChanged()
protected  void onSelectionChanged(java.lang.Object newSelection) 


I can't use either like:

  final DropDownChoice ddc = new DropDownChoice( "filterByJobProfileName",
jpNameString, renderer){
   void onSeclectionChanged(){
//I want to do somethign here if this is working :(
   }
};



Many thanks for your help!

  


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: DropDownChoice - how to get the current selected value and I can't use OnSelected event as well :(

2007-10-15 Thread raybristol



Gwyn wrote:
> 
> On Monday, October 15, 2007, 1:54:32 PM, raybristol <[EMAIL PROTECTED]>
> wrote:
> 
>> Hi, I am quite new to wicket and got 2 questions about DropDownChoice
>> don't
>> know how to solve even after some googling as well from this forum so
>> need
>> some helps again:
> 
> Have you found the wiki (http://cwiki.apache.org/WICKET/) yet?
> 
> See http://cwiki.apache.org/WICKET/dropdownchoice-examples.html,
> http://cwiki.apache.org/WICKET/another-dropdownchoice-example-by-adam.html
> and http://cwiki.apache.org/WICKET/custom-components.html for a start.
> 
> /Gwyn
> 
> 
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 
> 


Thanks very much! I did not find that before, that's great source!
-- 
View this message in context: 
http://www.nabble.com/DropDownChoice---how-to-get-the-current-selected-value-and-I-can%27t-use-OnSelected-event-as-well-%3A%28-tf4627230.html#a13213759
Sent from the Wicket - User mailing list archive at Nabble.com.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: DropDownChoice - how to get the current selected value and I can't use OnSelected event as well :(

2007-10-15 Thread Gwyn Evans
On Monday, October 15, 2007, 1:54:32 PM, raybristol <[EMAIL PROTECTED]> wrote:

> Hi, I am quite new to wicket and got 2 questions about DropDownChoice don't
> know how to solve even after some googling as well from this forum so need
> some helps again:

Have you found the wiki (http://cwiki.apache.org/WICKET/) yet?

See http://cwiki.apache.org/WICKET/dropdownchoice-examples.html,
http://cwiki.apache.org/WICKET/another-dropdownchoice-example-by-adam.html
and http://cwiki.apache.org/WICKET/custom-components.html for a start.

/Gwyn


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



DropDownChoice - how to get the current selected value and I can't use OnSelected event as well :(

2007-10-15 Thread raybristol

Hi, I am quite new to wicket and got 2 questions about DropDownChoice don't
know how to solve even after some googling as well from this forum so need
some helps again:

1. I want to get the current selected item's value from DropDownChoice, I
was looking for something like 

DropDownChoiceObject.selectedValueOrID() - something equitvalent, I saw the
example from wicket website, it's using:

DropDownChoice ddc = 
new DropDownChoice("name", 
new PropertyModel(employee, "managedBy"),
new LoadableDetachableModel() {
   ...
}
);

so do I have to pass in a PropertyModel to achieve what I want? mine is:

final Map choiceMap = new HashMap(); 
final List jpNameString = new ArrayList();
for (JobProfile j : jobProfiles){
choiceMap.put(String.valueOf(j.getId()), j.getName());
jpNameString.add(String.valueOf(j.getId()));
}
IChoiceRenderer renderer = new ChoiceRenderer() {
public Object getDisplayValue(Object object) {
return choiceMap.get(object);}
public String getIdValue(Object object, int index) { 
return object.toString(); 
} 

};

final DropDownChoice ddc = new DropDownChoice(
"filterByJobProfileName", jpNameString, renderer)


2. my second question is how to use event OnSelectionChange, I saw two
events from the API, one is final so I can't overide, one is pretected:

final void onSelectionChanged()
protected  void onSelectionChanged(java.lang.Object newSelection) 

I can't use either like:

  final DropDownChoice ddc = new DropDownChoice( "filterByJobProfileName",
jpNameString, renderer){
   void onSeclectionChanged(){
//I want to do somethign here if this is working :(
   }
};



Many thanks for your help!

-- 
View this message in context: 
http://www.nabble.com/DropDownChoice---how-to-get-the-current-selected-value-and-I-can%27t-use-OnSelected-event-as-well-%3A%28-tf4627230.html#a13212219
Sent from the Wicket - User mailing list archive at Nabble.com.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]