Re: RadioChoice : default choice ?
Thanks for the suggestion (to hit the Java Books, further), Per. I'm sure that is sage advice. However, just to clarify... - I am aware that RadioChoice *is* a different Type than String - my question: how is a RadioChoice value converted back and forth with a String? - It appears (to me) that RadioChoice is a Wicket Class (hence my question to Wicket Forum) Regarding Learning Path... I am accustomed to jumping around when learning and when I came across Wicket, it appeared to be a superior way to incorporate Java in a web environment. Thus, I have not studied any of the Swing stuff that most of the books contain. IMHO, I think Wicket would be an outstanding paradigm from which to *teach* Java. After all, the web is a very probable deployment platform for new Java projects. If Wicket *is* the *way*, I think there is a huge opportunity to train and indoctrinate new Java programmers, using Wicket from the get-go. For me, what has been confusing has been distinguishing where Wicket is deviating from standard Java. I sense that it could all come together quite nicely (for a java newbie), if beginner 'Java, the Wicket Way' resources were available. Thanks - Scott Newgro wrote: Am Freitag, 18. Januar 2008 23:43:18 schrieb scottomni: private RadioChoice genderChoice; public RadioChoice getGender(){ return genderChoice.getModelObjectAsString(); } public void setGender(){ this.genderChoice = Male; } Both of my Methods fail, due to incompatible Types. The cause of this is that Male is of type String and genderChoice is of type RadioChoice. But you can't say that an apple (RadioChoice) is an (=) orange (String). I would suggest, that you start with a good java book. Wicket is not the right place to start learning java. It's more a good start learning web-development. Hence, I don't get what I need to do to display a RadioChoice (on a Form) and Get/Set the values (which I will be storing in a database). Additional note: I am picked up 'getModelObjectAsString' from a Login Example. The example you should understand is here http://www.wicketstuff.org/wicket13/forminput/ There is a link in the upper right corner with source code. The classes FormInput.java and FormInputModel.java should help you out. Otherwise i really appriciate that you know the java basics before you start with wicket development. It makes it easier for everyone :-) Cheers Per - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- View this message in context: http://www.nabble.com/RadioChoice-%3A-default-choice---tp14876844p14998986.html 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: RadioChoice : default choice ?
Scott, To answer your last question, to set a selected value on the RadioChoice, you must set the PropertyModel's value to what you want selected. One thing that took me a while to figure out personally (and I have been programming in java for several years) is that the Object you set in the PropertyModel must be of the same type (class) as the objects in your list of choices. This is what Per was referring to. So if you have a list of Integers as choices, set the propertymodel to an integer. If you instead have a more complex Object (say MyChoiceObject) for your choices you use that. To render the choices, Wicket by default will just do ToString on the Object inthe choices list, unless you create an IChoiceRenderer. In any event, you need to set the PropertyModel's object to an object that is int he List of choices to preselect one of the objects. The example below is a good on, you should look at the RadioChoice and DropDownChoice, since they both use the same idea with their propertymodels. The point is that at some time, Wicket will try to cast one of the objects in the list into the variable in the propertymodel, so they have to have the same type. Hope this helps... -Clay Newgro wrote: The example you should understand is here http://www.wicketstuff.org/wicket13/forminput/ There is a link in the upper right corner with source code. The classes FormInput.java and FormInputModel.java should help you out. -- View this message in context: http://www.nabble.com/RadioChoice-%3A-default-choice---tp14876844p15001375.html 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: RadioChoice : default choice ?
Thanks Clay. I think I have reached a point in Wicket that is providing (me) the motivation to go 'back' to the Java Book and push forward (through the java learning curve). I'm getting there, slowly but surely. ;-) In the process, it looks like I will be familiarizing myself with the Swing library -- which, will probably enhance my appreciation (and understanding) of Wicket. Scott cblehman wrote: Scott, To answer your last question, to set a selected value on the RadioChoice, you must set the PropertyModel's value to what you want selected. One thing that took me a while to figure out personally (and I have been programming in java for several years) is that the Object you set in the PropertyModel must be of the same type (class) as the objects in your list of choices. This is what Per was referring to. So if you have a list of Integers as choices, set the propertymodel to an integer. If you instead have a more complex Object (say MyChoiceObject) for your choices you use that. To render the choices, Wicket by default will just do ToString on the Object inthe choices list, unless you create an IChoiceRenderer. In any event, you need to set the PropertyModel's object to an object that is int he List of choices to preselect one of the objects. The example below is a good on, you should look at the RadioChoice and DropDownChoice, since they both use the same idea with their propertymodels. The point is that at some time, Wicket will try to cast one of the objects in the list into the variable in the propertymodel, so they have to have the same type. Hope this helps... -Clay Newgro wrote: The example you should understand is here http://www.wicketstuff.org/wicket13/forminput/ There is a link in the upper right corner with source code. The classes FormInput.java and FormInputModel.java should help you out. -- View this message in context: http://www.nabble.com/RadioChoice-%3A-default-choice---tp14876844p15004489.html 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: RadioChoice : default choice ?
In the process, it looks like I will be familiarizing myself with the Swing library -- which, will probably enhance my appreciation (and understanding) of Wicket. Getting familiar with Swing will almost certainly help you get Wicket. Just keep in mind that with Swing, you would update values by 'pushing' them (for which you'd typically make heave use of the observer pattern, e.g. using PropertyChangeListeners etc), whereas with Wicket you would rely on the request cycle doing it for you (we often call that 'pull' and it is in fact an example of Inversion of Control, since you let your model objects being updated by the framework rather than pushing out changes to the framework yourself). Eelco - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: RadioChoice : default choice ?
Getting familiar with Swing will almost certainly help you get Wicket. Just keep in mind that with Swing, you would update values by 'pushing' them (for which you'd typically make heave use of the observer pattern, e.g. using PropertyChangeListeners etc), whereas with Wicket you would rely on the request cycle doing it for you (we often call that 'pull' and it is in fact an example of Inversion of Control, since you let your model objects being updated by the framework rather than pushing out changes to the framework yourself). Btw. on that issue you can checkout for the jgoodies binding framework. It has similiar concepts like wicket - but is for swing components. But i don't want to hijack this thread :-) Cheers Per - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: RadioChoice : default choice ?
On Jan 21, 2008 1:08 PM, Per Newgro [EMAIL PROTECTED] wrote: Getting familiar with Swing will almost certainly help you get Wicket. Just keep in mind that with Swing, you would update values by 'pushing' them (for which you'd typically make heave use of the observer pattern, e.g. using PropertyChangeListeners etc), whereas with Wicket you would rely on the request cycle doing it for you (we often call that 'pull' and it is in fact an example of Inversion of Control, since you let your model objects being updated by the framework rather than pushing out changes to the framework yourself). Btw. on that issue you can checkout for the jgoodies binding framework. It has similiar concepts like wicket - but is for swing components. But i don't want to hijack this thread :-) I've never used it myself, but I have heard good things about it. So yeah Scott, check it out :-) Eelco - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: RadioChoice : default choice ?
Am Freitag, 18. Januar 2008 23:43:18 schrieb scottomni: private RadioChoice genderChoice; public RadioChoice getGender(){ return genderChoice.getModelObjectAsString(); } public void setGender(){ this.genderChoice = Male; } Both of my Methods fail, due to incompatible Types. The cause of this is that Male is of type String and genderChoice is of type RadioChoice. But you can't say that an apple (RadioChoice) is an (=) orange (String). I would suggest, that you start with a good java book. Wicket is not the right place to start learning java. It's more a good start learning web-development. Hence, I don't get what I need to do to display a RadioChoice (on a Form) and Get/Set the values (which I will be storing in a database). Additional note: I am picked up 'getModelObjectAsString' from a Login Example. The example you should understand is here http://www.wicketstuff.org/wicket13/forminput/ There is a link in the upper right corner with source code. The classes FormInput.java and FormInputModel.java should help you out. Otherwise i really appriciate that you know the java basics before you start with wicket development. It makes it easier for everyone :-) Cheers Per - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: RadioChoice : default choice ?
Thanks Igor and Per. It appears that my ignorance is further complicated by RadioChoice... as I do not yet have a solution. Note: I have changed sexRadioChoice to genderChoice. Here is what I declare: private RadioChoice genderChoice; public RadioChoice getGender(){ return genderChoice.getModelObjectAsString(); } public void setGender(){ this.genderChoice = Male; } Both of my Methods fail, due to incompatible Types. Hence, I don't get what I need to do to display a RadioChoice (on a Form) and Get/Set the values (which I will be storing in a database). Additional note: I am picked up 'getModelObjectAsString' from a Login Example. Scott Newgro wrote: properties.setSexRadioChoice(MALE); What Igor tries to say (;-) is that you can set the default value to the object instance, which your checkbox is accessing. In your case this is properties. Simply do it before you render the page / checkbox. Because you set the property access expression to sexRadioChoice you have to provide a method named getSexRadioChoice / setSexRadioChoice(anything). The setter method can be used to achieve your goal. The short form was Igors answer. Cheers Per - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- View this message in context: http://www.nabble.com/RadioChoice-%3A-default-choice---tp14876844p14961435.html 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: RadioChoice : default choice ?
Sorry, I am new to Java (as well as Wicket). As it stands, I do not have a handle on Models. I have determined to head down the Wicket road (as I learn Java). Thus, I am looking for clear examples (which I am finding all too difficult to find). BTW, I am hoping your book will be written to educate 'new' Java programmers. OK. I have the following line in a Wicket Panel, which adds a RadioChoice to a Form. Is it not possible to modify my line of code to 'include' a default selection? - add(sexRadioChoice = (RadioChoice) new RadioChoice(sexRadioChoice, new PropertyModel(properties, sexRadioChoice),GENDERLIST).setSuffix().setRequired(true)); - If not, where and *how* do I set the model object? Thanks! - Scott set it in your model object. Martijn On 1/16/08, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Hello, I'm using a RadioChoice component like this : RadioChoice Radios = new RadioChoice(ca_reel, new PropertyModel(this.getModelObject(), ca_reel), Choices); I would like to know if I can have a default choice selected (the first in my variable List Choices) and if yes how ? (I didn't find on wicket API page nor that on examples) Thanks -- View this message in context: http://www.nabble.com/RadioChoice-%3A-default-choice---tp14876844p14957760.html 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: RadioChoice : default choice ?
On Jan 18, 2008 11:27 AM, scottomni [EMAIL PROTECTED] wrote: OK. I have the following line in a Wicket Panel, which adds a RadioChoice to a Form. Is it not possible to modify my line of code to 'include' a default selection? - add(sexRadioChoice = (RadioChoice) new RadioChoice(sexRadioChoice, new PropertyModel(properties, sexRadioChoice),GENDERLIST).setSuffix().setRequired(true)); - If not, where and *how* do I set the model object? properties.setSexRadioChoice(MALE); -igor - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: RadioChoice : default choice ?
set it in your model object. Martijn On 1/16/08, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Hello, I'm using a RadioChoice component like this : RadioChoice Radios = new RadioChoice(ca_reel, new PropertyModel(this.getModelObject(), ca_reel), Choices); I would like to know if I can have a default choice selected (the first in my variable List Choices) and if yes how ? (I didn't find on wicket API page nor that on examples) Thanks - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- Buy Wicket in Action: http://manning.com/dashorst Apache Wicket 1.3.0 is released Get it now: http://www.apache.org/dyn/closer.cgi/wicket/1.3.0 - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RadioChoice : default choice ?
Hello, I'm using a RadioChoice component like this : RadioChoice Radios = new RadioChoice(ca_reel, new PropertyModel(this.getModelObject(), ca_reel), Choices); I would like to know if I can have a default choice selected (the first in my variable List Choices) and if yes how ? (I didn't find on wicket API page nor that on examples) Thanks - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]