My bad.  I missed that part when I copied and pasted.  

                        comboChoiceDropDown.add(new 
AjaxFormComponentUpdatingBehavior("onchange")
                {
                    protected void onUpdate(AjaxRequestTarget target)
                    {
                        target.addComponent(weeksDropDown);
                    }
                });



tdelesio wrote:
> 
> Hi,
> 
> I have two dropdowns.  Once you select a value from the first dropdown the
> second dropdown is populated using ajax.  I got this to work based on the
> example on wicketstuff.  But when I submit the form the model is null-ed
> out.  I tried to remove the ajax call and then re-submit the form and the
> model is fine so it looks like the ajax call is actually nulling out my
> model.  Here is the code.
> 
> AdminSelection adminSelection = new AdminSelection();
>               adminSelection.setWeek(weekStartInfo.getCurrentWeek());
>               adminSelection.setLeagueType("ncaa");
> 
> Form form = new Form("selectWeekForm", new
> CompoundPropertyModel(adminSelection))
>               {
>                       @Override
>                       protected void onSubmit() {
>                               //super.onSubmit();get
>                               AdminSelection adminSelection = 
> (AdminSelection)getModelObject();
> System.out.println(adminSelection);                           
>                               
> getAdminSelection().setWeek(adminSelection.getWeek());
>                               
> getAdminSelection().setLeagueType(adminSelection.getLeagueType());
>                               setResponsePage(redirection);
>                       }
>               };
>               add(form);
> 
> IModel weeks = new AbstractReadOnlyModel()
>                       {
>                               public Object getObject()
>                   {
>                                       List<WeekStartInfo> weeks;
>                                       
>                                       try
>                                       {
> //System.out.println(selectedType.getLeagueType());   
>                                               
>                                               weeks =
> weekStartManager.getAllWeeksFromDB(selectedType.getLeagueType());
>                                       }
>                                       catch (SystemException systemException)
>                                       {
>                                               
> systemException.printStackTrace();
>                                               weeks = Collections.EMPTY_LIST;
>                                       }
>                       if (weeks == null)
>                       {
>                               weeks = Collections.EMPTY_LIST;
>                       }
>                       return weeks;
>                   }
>                       };
> 
> List<LeagueInfo> leagueTypes = leagueManager.getLeagueTypes();
>                       final DropDownChoice comboChoiceDropDown = new
> DropDownChoice("leagueType", new PropertyModel(this, "selectedType"),
> leagueTypes, 
>                                       //new 
> ChoiceRenderer("leagueTypeDisplay", "leagueType"));
>                                       new LeagueTypeChoiceRenderer());
>                       comboChoiceDropDown.setRequired(true);
>                       comboChoiceDropDown.setLabel(new Model("League Type"));
>                       form.add(comboChoiceDropDown);
>                       
>                       final DropDownChoice weeksDropDown = new DropDownChoice(
>                                       "week", new CompoundPropertyModel(new 
> WeekStartInfo()), weeks, new
> ChoiceRenderer(
>                                                       "selectedWeek", 
> "selectedWeek"));
>                       //weeksDropDown.setRequired(true);
>                       weeksDropDown.setOutputMarkupId(true);
>                       form.add(weeksDropDown);
> 
> public class AdminSelection extends BaseInfo {
> 
>       private String leagueType;
>       private int week=-1;
>       
>       
>       /**
>        * Constructs a <code>String</code> with all attributes
>        * in name = value format.
>        *
>        * @return a <code>String</code> representation 
>        * of this object.
>        */
>       public String toString()
>       {
>           final String TAB = "    ";
>           
>           String retValue = "";
>           
>           retValue = "AdminSelection ( "
>               + "leagueType = " + this.leagueType + TAB
>               + "week = " + this.week + TAB
>               + " )";
>       
>           return retValue;
>       }
> 
> 
>       public String getLeagueType() {
>               return leagueType;
>       }
> 
> 
>       public void setLeagueType(String leagueType) {
>               this.leagueType = leagueType;
>       }
> 
> 
>       public int getWeek() {
>               return week;
>       }
> 
> 
>       public void setWeek(int week) {
>               this.week = week;
>       }
>       
>       public boolean isAdminLeagueSet()
>       {
>               if (leagueType==null||leagueType.equalsIgnoreCase(""))
>               {
>                       return false;
>               }
>               else
>               {
>                       return true;
>               }
>       }
>       
>       public void invailateAdminLeagueType()
>       {
>               leagueType=null;
>       }
> 
> The ObjectModel has null values in the onSubmit().  Any suggestions or
> something that I am doing wrong?
> 

-- 
View this message in context: 
http://www.nabble.com/AJAX-Dropdown-Choices-cleared-on-submit-tp16251739p16253522.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]

Reply via email to