Make sure you fully understand how CompoundPropertyModel and
PropertyModel work first.
I suggest to study some documentation about CompoundPropertyModel (as
in [1], [2] or [3])
and to do some googleing for code examples.

[1] <http://cwiki.apache.org/WICKET/working-with-wicket-models.html>
[2] 
<http://www.javabeat.net/javabeat/wicket/tutorials/basics/4-more-on-models.php>
[3] <http://wicketinaction.com/book/>


On Thu, Jan 21, 2010 at 9:28 AM, chinedu efoagui <chinedub...@gmail.com> wrote:
> @jonas
>
> Thanks a lot for your help but could illustrate with some code please
> so i can get the full idea
> ..........
>
>
> On 1/20/10, Jonas <barney...@gmail.com> wrote:
>> with this code, you're trying to set a PersonnelrecordsDepartment Object
>> into the field called parentId of the object referred to by the
>> 'selected' variable
>> that you're passing to the CompoundPropertyModel. The data types don't
>> match, that's why wicket trys to safe the day using conversion (which
>> obviously
>> cannot succeed in this case...).
>> You can either:
>> a) change the data type of the parentId field of your 'selected' object
>> or
>> b) change your dropdown choice so only the id is propagated instead of the
>> whole PersonnelrecordsDepartment Object. you could do that e.g. by
>> setting the ids
>> as choices, and use a custom choicerenderer which retrieves and
>> renders the PersonnelrecordsDepartment Objects
>>
>> I hope that helps...
>>
>> On Wed, Jan 20, 2010 at 4:54 PM, chinedu efoagui <chinedub...@gmail.com>
>> wrote:
>>> @jonas ignore that. i was just refactoring the code for the email.
>>> the error is runtime not compile time.
>>> I think it is a conversion problem
>>> please help
>>> The field parentid is integer but the dropdown is expecting object
>>> the form
>>> <code>
>>> IModel zaModel=new CompoundPropertyModel(selected);
>>>        departmentform.setModel(zaModel);
>>>        RequiredTextField  departmentname=new
>>> RequiredTextField("departmentname");
>>>        departmentname.setOutputMarkupId(true);
>>>        departmentform.add(departmentname);
>>>
>>>        DepartmentDropDownChoice title=new
>>> DepartmentDropDownChoice("parentid",zaModel);
>>>        departmentform.add(title);
>>>
>>>        departmentform.add(new
>>> AjaxFallbackLink("canceldepartmentformbutton"){
>>>
>>>               �...@override
>>>                public void onClick(AjaxRequestTarget target) {
>>>                   closeModalWindow(target);
>>>
>>>                }
>>>
>>>
>>>        });
>>>        feedback = new FeedbackPanel("feedback");
>>>      feedback.setOutputMarkupId(true);
>>>      int[] filteredErrorLevels = new int[]{FeedbackMessage.ERROR};
>>>      feedback.setFilter(new
>>> ErrorLevelsFeedbackMessageFilter(filteredErrorLevels));
>>>     departmentform.add(feedback);
>>>
>>>
>>>        FeedbackLabel departmentFeedbackLabel = new
>>> FeedbackLabel("departmentfeedback", departmentname,new
>>> Model("Department is required"));
>>>        departmentFeedbackLabel.setOutputMarkupId(true);
>>>        departmentname.add(new ComponentVisualErrorBehavior("onblur",
>>> departmentFeedbackLabel));
>>>        departmentform.add(departmentFeedbackLabel);
>>>
>>>
>>>      departmentform.add(new
>>> AjaxFallbackButton("savedepartmentbutton", departmentform) {
>>>
>>>           @Override
>>>      protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
>>>
>>>       PersonnelrecordsDepartment
>>> pr=(PersonnelrecordsDepartment)form.getDefaultModel().getObject();
>>>
>>>        try {
>>>            if(isNew){
>>>            dao.addPersonnelrecordsDepartment(pr);
>>>            }
>>>            else{
>>>
>>>            dao.savePersonnelrecordsDepartment(pr);
>>>            }
>>>        } catch (GenericBusinessException ex) {
>>>
>>>  Logger.getLogger(DepartmentPanel.class.getName()).log(Level.SEVERE,
>>> null, ex);
>>>        }
>>>        //target.addComponent(form);
>>>        setFormReponse(target);
>>>
>>>    }
>>>
>>>         @Override
>>>                        protected void onError(AjaxRequestTarget target,
>>> Form<?> form)
>>>                        {
>>>                        // repaint the feedback panel so errors are shown
>>>
>>>                           target.addComponent(feedback);
>>>                        }
>>>
>>>            });
>>>
>>>        add(departmentform);
>>>    }
>>>        private void setFormReponse(AjaxRequestTarget target){
>>>
>>>
>>>            info("Save Operation was Successful");
>>>
>>>            target.addComponent(feedback);
>>>
>>>  }
>>>    FeedbackPanel feedback;
>>>
>>>
>>>    }
>>>
>>>
>>> </code>
>>>
>>> On 1/20/10, Jonas <barney...@gmail.com> wrote:
>>>> not sure if that's the problem, but shouldn't
>>>>
>>>> setChoices(titles);
>>>>
>>>> be
>>>>
>>>> setChoices(departments);
>>>>
>>>>
>>>>
>>>>
>>>> On Wed, Jan 20, 2010 at 4:14 PM, chinedu efoagui <chinedub...@gmail.com>
>>>> wrote:
>>>>> Hello , I have a class PersonnelrecordsDepartment
>>>>>  with the following fields with corresponding getters and setters
>>>>>   private java.lang.Integer id;
>>>>>   private java.lang.String departmentname;
>>>>>   private java.lang.Integer parentid;
>>>>>
>>>>> I left out the getters and setters . Any the field parentid can refer
>>>>> to an existing department like a recursive stuff like having a self
>>>>> foreign key
>>>>> Anyway the problem is that i have a dropdownlchoice for the form
>>>>> <code>
>>>>> public class DepartmentDropDownChoice extends DropDownChoice {
>>>>>
>>>>>   �...@springbean(name="IHRService")
>>>>>    private  IHRService dao;
>>>>>
>>>>> */    /**
>>>>>     *
>>>>>     * @param id
>>>>>     * @param model
>>>>>     */
>>>>>    public DepartmentDropDownChoice(String id,final IModel model){
>>>>>
>>>>>        super(id,model);
>>>>>        final ChoiceRenderer renderer = new
>>>>> ChoiceRenderer("departmentname", "id");
>>>>>
>>>>>        setChoiceRenderer(renderer);
>>>>>        List<PersonnelrecordsDepartment>
>>>>> departments=Collections.EMPTY_LIST;
>>>>>        try {
>>>>>           departments = dao.getPersonnelrecordsDepartmentList();
>>>>>        } catch (GenericBusinessException ex) {
>>>>>
>>>>>  Logger.getLogger(DepartmentDropDownChoice.class.getName()).log(Level.SEVERE,
>>>>> null, ex);
>>>>>        }
>>>>>        setChoices(titles);
>>>>>    }
>>>>> </code>
>>>>>
>>>>> and it gives this error anytime i try to save the personneldepartment
>>>>> object
>>>>> <code>
>>>>> 2010-01-20 16:12:07,745 ERROR [org.apache.wicket.RequestCycle] -
>>>>> <Cannot format given Object as a Number>
>>>>> java.lang.IllegalArgumentException: Cannot format given Object as a
>>>>> Number
>>>>>        at java.text.DecimalFormat.format(DecimalFormat.java:487)
>>>>>        at java.text.Format.format(Format.java:140)
>>>>>        at
>>>>> org.apache.wicket.util.convert.converters.AbstractNumberConverter.convertToString(AbstractNumberConverter.java:111)
>>>>>        at
>>>>> org.apache.wicket.util.lang.PropertyResolverConverter.convert(PropertyResolverConverter.java:85)
>>>>>        at
>>>>> org.apache.wicket.util.lang.PropertyResolver$MethodGetAndSet.setValue(PropertyResolver.java:1107)
>>>>>        at
>>>>> org.apache.wicket.util.lang.PropertyResolver$ObjectAndGetSetter.setValue(PropertyResolver.java:588)
>>>>>        at
>>>>> org.apache.wicket.util.lang.PropertyResolver.setValue(PropertyResolver.java:136)
>>>>>        at
>>>>> org.apache.wicket.model.AbstractPropertyModel.setObject(AbstractPropertyModel.java:169)
>>>>>        at
>>>>> org.apache.wicket.Component.setDefaultModelObject(Component.java:3052)
>>>>>        at
>>>>> org.apache.wicket.markup.html.form.FormComponent.updateModel(FormComponent.java:1168)
>>>>>        at
>>>>> org.apache.wicket.markup.html.form.Form$FormModelUpdateVisitor.component(Form.java:225)
>>>>>        at
>>>>> org.apache.wicket.markup.html.form.FormComponent.visitComponentsPostOrderHelper(FormComponent.java:514)
>>>>>        at
>>>>> org.apache.wicket.markup.html.form.FormComponent.visitComponentsPostOrderHelper(FormComponent.java:493)
>>>>>        at
>>>>> org.apache.wicket.markup.html.form.FormComponent.visitComponentsPostOrder(FormComponent.java:465)
>>>>>        at
>>>>> org.apache.wicket.markup.html.form.Form.internalUpdateFormComponentModels(Form.java:2051)
>>>>>        at
>>>>> org.apache.wicket.markup.html.form.Form.updateFormComponentModels(Form.java:2019)
>>>>>        at org.apache.wicket.markup.html.form.Form.process(Form.java:984)
>>>>>        at org.apache.wicket.markup.html.form.Form.process(Form.java:911)
>>>>>        at
>>>>> org.apache.wicket.markup.html.form.Form.onFormSubmitted(Form.java:876)
>>>>>        at
>>>>> org.apache.wicket.ajax.form.AjaxFormSubmitBehavior.onEvent(AjaxFormSubmitBehavior.java:135)
>>>>>        at
>>>>> org.apache.wicket.ajax.AjaxEventBehavior.respond(AjaxEventBehavior.java:177)
>>>>>        at
>>>>> org.apache.wicket.ajax.AbstractDefaultAjaxBehavior.onRequest(AbstractDefaultAjaxBehavior.java:299)
>>>>>
>>>>> </code>
>>>>>
>>>>> i think it has something to do with the conversion. but how do i
>>>>> convert it again??
>>>>> How can i solve this problem???
>>>>>
>>>>> ---------------------------------------------------------------------
>>>>> 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
>>>>
>>>>
>>>
>>> ---------------------------------------------------------------------
>>> 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
>>
>>
>
> ---------------------------------------------------------------------
> 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

Reply via email to