HI,

try giving a model to your RadioGroup:

final RadioGroup<Presentation> group = new RadioGroup<Presentation>("presentationSingleSelectGroup", new Model<Presentation>());


Hi All,

My company has just started evaluating Wicket on an app that allows users to 
select and merge multiple PowerPoint presentations.

We’ve hit a bit of a problem though, basically at the moment we have one long 
form containing a number of section panels.

The section panels are either ‘multi select’ (a Panel containing a CheckGroup 
that contains Check objects representing the PowerPoint presentations in that 
section) or ‘single select’ (a Panel containing a RadioGroup that contains 
Radio objects).

The problem happens when a validation failure occurs. Basically the checkboxes 
that the user selected prior to the validation failure are remembered and 
repopulated when the user is bounced back to the page but the radio buttons 
that the user selected aren’t remembered.

Any help would be gratefully received, I’ve snipped out what I think are the 
relevant bits of code below...

Thanks
Matt


FORM CODE:
______________

public class PresentationSelectionForm extends 
Form<PresentationSelectionFormModel>  implements Serializable
{
     private static final long serialVersionUID = 5962930827736414107L;

     final DownloadLinkPanel dlPanel = 
DownloadLinkPanel.getEmptyLink("downloadLinkPanel");
     final HiddenField<String>  messageIndicator = new HiddenField<String>("messageIndicator", 
new Model<String>("0"));

     private List<PresentationSelector>  selectors = new 
ArrayList<PresentationSelector>();

     @SpringBean
     private AssetBankService assetBankService;



     public PresentationSelectionForm(String name, List<Section>  sections, 
final PageParameters parameters)
     {
         super(name, new 
CompoundPropertyModel<PresentationSelectionFormModel>(new 
PresentationSelectionFormModel()));

         add(new FeedbackPanel("feedback"));
         add(dlPanel);
         add(messageIndicator);

         HiddenField<String>  mandatorySections = new 
HiddenField<String>("requiredSections", new 
Model<String>(getIdListFromMandatorySections(sections)));
         add(mandatorySections);

         ListView<Section>  sectionList = new ListView<Section>("sections", 
sections)
         {
             private static final long serialVersionUID = 7480938703389583883L;

             protected void populateItem(ListItem<Section>  sectionItem)
             {
                 sectionItem.add(new Label("sectionTitle", 
sectionItem.getModelObject().getTitle()));
                 PresentationMultiSelectPanel multi = new 
PresentationMultiSelectPanel("presentationMultiSelectPanel", sectionItem);
                 PresentationSingleSelectPanel single = new 
PresentationSingleSelectPanel("presentationSingleSelectPanel", sectionItem);
                 selectors.add(multi);
                 selectors.add(single);
                 sectionItem.add(multi);
                 sectionItem.add(single);
             }
         };

         sectionList.setReuseItems(true);
         add(sectionList);
     }



     @Override
     public void onSubmit()
     {
         //create the list of asset bank ids to merge from the panel input...
         List<Long>  assetBankAssetIds = new ArrayList<Long>();

         for (PresentationSelector selector : selectors)
         {
             assetBankAssetIds.addAll(selector.getSelectedAssetBankAssetIds());
         }

         if (assetBankAssetIds.size() == 0)
         {
             error("Unable to complete merge, no presentations were selected. Please 
select from the list then try again");
         }
         else if (!allMandatorySectionsAreCompleted())
         {
             error("Unable to complete merge, not all mandatory sections were 
completed. Please complete all mandatory sections and try again");
         }
         else
         {
             try
             {
                 File mergedPresentations = 
assetBankService.getMergedPresentations(assetBankAssetIds);
                 
addOrReplace(DownloadLinkPanel.getLinkToResourceFile("downloadLinkPanel", 
mergedPresentations, "Download your file: "+mergedPresentations.getName()));
             }
             catch (IOException e)
             {
                 throw new RuntimeException("Error merging presentations", e);
             }
         }

         addOrReplace(new HiddenField<String>("messageIndicator", new 
Model<String>("1")));
     }
}



SINGLE SELECT PANEL CODE:
________________________



public class PresentationSingleSelectPanel extends Panel implements 
PresentationSelector, Serializable
{
     private static final long serialVersionUID = 7062146893868378278L;

     private Section section;
     final RadioGroup<Presentation>  group = new 
RadioGroup<Presentation>("presentationSingleSelectGroup");

     public PresentationSingleSelectPanel(String id, ListItem<Section>  
sectionItem)
     {
         super(id);
         section = sectionItem.getModelObject();

         ListView<Presentation>  presentations = new 
ListView<Presentation>("presentations", 
sectionItem.getModelObject().getPresentations())
         {
             private static final long serialVersionUID = -2741478778745270525L;

             protected void populateItem(ListItem<Presentation>  
presentationItem)
             {
                 presentationItem.add(new Radio<Presentation>("presentation", 
presentationItem.getModel()));
                 presentationItem.add(new Label("presentationLabel", 
presentationItem.getModelObject().getName()));
                 presentationItem.add(new 
PresentationThumbnailsPanel("presentationThumbnailPanel", presentationItem));
             }
         };

         presentations.setReuseItems(true);
         group.add(presentations);
         add(group);
     }
}




MULTI SELECT PANEL CODE:
________________________


public class PresentationMultiSelectPanel extends Panel implements 
PresentationSelector, Serializable
{
     private static final long serialVersionUID = 1024114105801324440L;

     private Section section;
     final CheckGroup<Presentation>  multiGroup = new 
CheckGroup<Presentation>("presentationMultiSelectGroup", new 
ArrayList<Presentation>());


     public PresentationMultiSelectPanel(String id, ListItem<Section>  
sectionItem)
     {
         super(id);
         section = sectionItem.getModelObject();

         ListView<Presentation>  presentations = new 
ListView<Presentation>("presentations", 
sectionItem.getModelObject().getPresentations())
         {
             private static final long serialVersionUID = 1397844164166900201L;

             protected void populateItem(ListItem<Presentation>  
presentationItem)
             {
                 presentationItem.add(new Check<Presentation>("presentation", 
presentationItem.getModel()));
                 presentationItem.add(new Label("presentationLabel", 
presentationItem.getModelObject().getName()));
                 presentationItem.add(new 
PresentationThumbnailsPanel("presentationThumbnailPanel", presentationItem));
             }
         };

         presentations.setReuseItems(true);
         multiGroup.add(presentations);
         add(multiGroup);
     }
}


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

Reply via email to