Re: RadioGroup selections after validation failure problem

2012-04-03 Thread Matt Stevenson

Hi Andrea,

That solved the problem - I should have noticed it was missing the model 
myself!


Thanks so much for the help.
Matt


-Original Message- 
From: Andrea Del Bene

Sent: Monday, April 02, 2012 6:36 PM
To: users@wicket.apache.org
Subject: Re: RadioGroup selections after validation failure problem

HI,

try giving a model to your RadioGroup:

final RadioGroupPresentation group = new
RadioGroupPresentation(presentationSingleSelectGroup, new
ModelPresentation());



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 
FormPresentationSelectionFormModel  implements Serializable

{
 private static final long serialVersionUID = 5962930827736414107L;

 final DownloadLinkPanel dlPanel = 
DownloadLinkPanel.getEmptyLink(downloadLinkPanel);
 final HiddenFieldString  messageIndicator = new 
HiddenFieldString(messageIndicator, new ModelString(0));


 private ListPresentationSelector  selectors = new 
ArrayListPresentationSelector();


 @SpringBean
 private AssetBankService assetBankService;



 public PresentationSelectionForm(String name, ListSection 
sections, final PageParameters parameters)

 {
 super(name, new 
CompoundPropertyModelPresentationSelectionFormModel(new 
PresentationSelectionFormModel()));


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

 HiddenFieldString  mandatorySections = new 
HiddenFieldString(requiredSections, new 
ModelString(getIdListFromMandatorySections(sections)));

 add(mandatorySections);

 ListViewSection  sectionList = new 
ListViewSection(sections, sections)

 {
 private static final long serialVersionUID = 
7480938703389583883L;


 protected void populateItem(ListItemSection  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...

 ListLong  assetBankAssetIds = new ArrayListLong();

 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 HiddenFieldString(messageIndicator, new 
ModelString(1)));

 }
}



SINGLE SELECT PANEL CODE:




public class PresentationSingleSelectPanel extends Panel implements 
PresentationSelector, Serializable

{
 private static final long serialVersionUID = 7062146893868378278L;

 private Section section

Re: RadioGroup selections after validation failure problem

2012-04-02 Thread Andrea Del Bene

HI,

try giving a model to your RadioGroup:

final RadioGroupPresentation group = new 
RadioGroupPresentation(presentationSingleSelectGroup, new 
ModelPresentation());




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 
FormPresentationSelectionFormModel  implements Serializable
{
 private static final long serialVersionUID = 5962930827736414107L;

 final DownloadLinkPanel dlPanel = 
DownloadLinkPanel.getEmptyLink(downloadLinkPanel);
 final HiddenFieldString  messageIndicator = new HiddenFieldString(messageIndicator, 
new ModelString(0));

 private ListPresentationSelector  selectors = new 
ArrayListPresentationSelector();

 @SpringBean
 private AssetBankService assetBankService;



 public PresentationSelectionForm(String name, ListSection  sections, 
final PageParameters parameters)
 {
 super(name, new 
CompoundPropertyModelPresentationSelectionFormModel(new 
PresentationSelectionFormModel()));

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

 HiddenFieldString  mandatorySections = new 
HiddenFieldString(requiredSections, new 
ModelString(getIdListFromMandatorySections(sections)));
 add(mandatorySections);

 ListViewSection  sectionList = new ListViewSection(sections, 
sections)
 {
 private static final long serialVersionUID = 7480938703389583883L;

 protected void populateItem(ListItemSection  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...
 ListLong  assetBankAssetIds = new ArrayListLong();

 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 HiddenFieldString(messageIndicator, new 
ModelString(1)));
 }
}



SINGLE SELECT PANEL CODE:




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

 private Section section;
 final RadioGroupPresentation  group = new 
RadioGroupPresentation(presentationSingleSelectGroup);

 public PresentationSingleSelectPanel(String id, ListItemSection  
sectionItem)
 {
 super(id);
 section = sectionItem.getModelObject();

 ListViewPresentation  presentations