You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by chinedu efoagui <ch...@gmail.com> on 2010/03/27 15:18:54 UTC

drop down problem

Hello all,
 I have this dropdown that shows up a list of employee see code below

<code>
 public EmployeeDropDownChoice(String id,IModel model,IModel model2){

        super(id,model,model2);
        final ChoiceRenderer renderer  = new ChoiceRenderer("fullname", "id");

        setChoiceRenderer(renderer);
        List<PersonnelrecordsEmployee> emps=Collections.EMPTY_LIST;
        try {
            emps = dao.getPersonnelrecordsEmployeeList();
        } catch (GenericBusinessException ex) {
            Logger.getLogger(EmployeeDropDownChoice.class.getName()).log(Level.SEVERE,
null, ex);
        }
        setChoices(emps);
    }
</code>

Now in the panel/form when i call it since the form uses a
CompoundPropertyModel I declare the dropdown like this
 final EmployeeDropDownChoice forwardofficer=new
EmployeeDropDownChoice("forwardofficer",new Model(),new Model(""));
      to avoid compoundpropertymodel issues is the EmployeeDropdown is
not a member of the backing object of the form.
NOw this is the problem

when i try to get the defaultmodelobject from the Employeedropdown it
give me null.
How do i retrieve the selected choice from the Employeedropdown??
<code>
  final AjaxFallbackLink forwardbutton=new AjaxFallbackLink("forwardbutton") {
                    @Override
                public void onClick(AjaxRequestTarget art) {

                   final LeaveappEmpleaveApprovalOfficers
leaveappOfficerss=new LeaveappEmpleaveApprovalOfficers();
                    leaveappOfficerss.setEmpleaveIdLeaveappEmpleave(selected);
                    //PersonnelrecordsEmployee
zaemployeee=(PersonnelrecordsEmployee)forwardofficer.getDefaultModelObject();
                    //System.out.println("personnel
id:"+zaemployeee.getFullname() );
                    System.out.println("personnel
id:"+forwardofficer.getDefaultModelObject());
                    try {

dao.addLeaveappEmpleaveApprovalOfficers(leaveappOfficerss);
                       </code>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: drop down problem

Posted by chinedu efoagui <ch...@gmail.com>.
thanks martin it worked

On Sat, Mar 27, 2010 at 3:24 PM, Martin Makundi
<ma...@koodaripalvelut.com> wrote:
> ajax link does not submit form..  use submitlink or ajaxbutton
>
> **
> Martin
>
> 2010/3/27 chinedu efoagui <ch...@gmail.com>:
>> Hello all,
>>  I have this dropdown that shows up a list of employee see code below
>>
>> <code>
>>  public EmployeeDropDownChoice(String id,IModel model,IModel model2){
>>
>>        super(id,model,model2);
>>        final ChoiceRenderer renderer  = new ChoiceRenderer("fullname", "id");
>>
>>        setChoiceRenderer(renderer);
>>        List<PersonnelrecordsEmployee> emps=Collections.EMPTY_LIST;
>>        try {
>>            emps = dao.getPersonnelrecordsEmployeeList();
>>        } catch (GenericBusinessException ex) {
>>            Logger.getLogger(EmployeeDropDownChoice.class.getName()).log(Level.SEVERE,
>> null, ex);
>>        }
>>        setChoices(emps);
>>    }
>> </code>
>>
>> Now in the panel/form when i call it since the form uses a
>> CompoundPropertyModel I declare the dropdown like this
>>  final EmployeeDropDownChoice forwardofficer=new
>> EmployeeDropDownChoice("forwardofficer",new Model(),new Model(""));
>>      to avoid compoundpropertymodel issues is the EmployeeDropdown is
>> not a member of the backing object of the form.
>> NOw this is the problem
>>
>> when i try to get the defaultmodelobject from the Employeedropdown it
>> give me null.
>> How do i retrieve the selected choice from the Employeedropdown??
>> <code>
>>  final AjaxFallbackLink forwardbutton=new AjaxFallbackLink("forwardbutton") {
>>                    @Override
>>                public void onClick(AjaxRequestTarget art) {
>>
>>                   final LeaveappEmpleaveApprovalOfficers
>> leaveappOfficerss=new LeaveappEmpleaveApprovalOfficers();
>>                    leaveappOfficerss.setEmpleaveIdLeaveappEmpleave(selected);
>>                    //PersonnelrecordsEmployee
>> zaemployeee=(PersonnelrecordsEmployee)forwardofficer.getDefaultModelObject();
>>                    //System.out.println("personnel
>> id:"+zaemployeee.getFullname() );
>>                    System.out.println("personnel
>> id:"+forwardofficer.getDefaultModelObject());
>>                    try {
>>
>> dao.addLeaveappEmpleaveApprovalOfficers(leaveappOfficerss);
>>                       </code>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: drop down problem

Posted by Martin Makundi <ma...@koodaripalvelut.com>.
ajax link does not submit form..  use submitlink or ajaxbutton

**
Martin

2010/3/27 chinedu efoagui <ch...@gmail.com>:
> Hello all,
>  I have this dropdown that shows up a list of employee see code below
>
> <code>
>  public EmployeeDropDownChoice(String id,IModel model,IModel model2){
>
>        super(id,model,model2);
>        final ChoiceRenderer renderer  = new ChoiceRenderer("fullname", "id");
>
>        setChoiceRenderer(renderer);
>        List<PersonnelrecordsEmployee> emps=Collections.EMPTY_LIST;
>        try {
>            emps = dao.getPersonnelrecordsEmployeeList();
>        } catch (GenericBusinessException ex) {
>            Logger.getLogger(EmployeeDropDownChoice.class.getName()).log(Level.SEVERE,
> null, ex);
>        }
>        setChoices(emps);
>    }
> </code>
>
> Now in the panel/form when i call it since the form uses a
> CompoundPropertyModel I declare the dropdown like this
>  final EmployeeDropDownChoice forwardofficer=new
> EmployeeDropDownChoice("forwardofficer",new Model(),new Model(""));
>      to avoid compoundpropertymodel issues is the EmployeeDropdown is
> not a member of the backing object of the form.
> NOw this is the problem
>
> when i try to get the defaultmodelobject from the Employeedropdown it
> give me null.
> How do i retrieve the selected choice from the Employeedropdown??
> <code>
>  final AjaxFallbackLink forwardbutton=new AjaxFallbackLink("forwardbutton") {
>                    @Override
>                public void onClick(AjaxRequestTarget art) {
>
>                   final LeaveappEmpleaveApprovalOfficers
> leaveappOfficerss=new LeaveappEmpleaveApprovalOfficers();
>                    leaveappOfficerss.setEmpleaveIdLeaveappEmpleave(selected);
>                    //PersonnelrecordsEmployee
> zaemployeee=(PersonnelrecordsEmployee)forwardofficer.getDefaultModelObject();
>                    //System.out.println("personnel
> id:"+zaemployeee.getFullname() );
>                    System.out.println("personnel
> id:"+forwardofficer.getDefaultModelObject());
>                    try {
>
> dao.addLeaveappEmpleaveApprovalOfficers(leaveappOfficerss);
>                       </code>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org