Maybe that class should operate in on an IModel<Path>

On Tue, Aug 5, 2025 at 11:27 AM andrew goh <gohand...@yahoo.com.invalid>
wrote:

> I managed to work around / resolve the FileSystemResourceReference
> serialization error
>
>
> https://github.com/apache/wicket/blob/ebfd87c5c796c3a0da1350e797b330b5fcfa3f90/wicket-core/src/main/java/org/apache/wicket/resource/FileSystemResourceReference.java#L95
>
> FileSystemResourceReference has a Path instance variable that connects
> deep into the JDK to classes that cannot be serialized.
>
> my work around is to make a custom copy of FileSystemResourceReference
> and to replace that Path instance variable with something else e.g. a
> String etc.
> And to parse that into a Path as necessary when methods are called. That
> resolved the serialization issue sort of.
>
> On 05/08/2025 23:47, andrew goh wrote:
> >
> > oh it seemed I found some examples
> >
> > where there are 2 radio groups, the 2nd group needs to be added to the
> > 1st group
> >
> >
> https://github.com/apache/wicket/blob/master/wicket-examples/src/main/java/org/apache/wicket/examples/compref/RadioGroupPage2.java
> >
> > then that the ListView is added to the 2nd radio group.
> >
> > I'm still needing to solve a serialization problem as it seemed adding
> > things this way resulted in all java components used in the ListView
> > being serialized, even if they are not literally a component.
> > As I'm using FileSystemResourceReference, components deep down even
> > within jdk gets pulled in as java.util.Path is used, that breaks when
> > things like Images are used.
> >
> > Is there a means to exclude some components from being serialized?
> > e.g. those images used in the ListView are display only items, in a
> > sense they do not keep a changing state.
> > e.g. the same url that references an image (e.g. <img src="url">
> > mostly stays the same and can be reconstructed again rather than being
> > serialized.
> >
> > but that the Image is like
> >
> > Image image = new Image("image", new
> > FileSystemResourceReference("imageref",Paths.get( some_paths ));
> >
> > This hit a bummer when it is serialized as there is a Path instance
> > variable in FileSystemResource reference, and it hit objects that
> > cannot be serialized error digging deep down into the JDK during
> > serialization.
> >
> > That occurs when the Image is part of the ListView is added to the
> > RadioGroup which is inside a Form.
> >
> > I'm not sure how to fix this serialization error as well.
> >
> > On 05/08/2025 23:01, andrew goh wrote:
> >>
> >> it turns out I  did not solve the issue.
> >>
> >> If I leave the radio group on its own (as an orphan), instead of
> >> adding the ListView to it I get an error
> >>
> >> Last cause: submitted http post value [radio0] for RadioGroup
> >> component [3:Form:radioGroup] is illegal because it does not point to
> >> a Radio component. Due to this the RadioGroup component cannot
> >> resolve the selected Radio component pointed to by the illegal value.
> >> A possible reason is that component hierarchy changed between
> >> rendering and form submission.
> >>
> >> But if I add a rather complex ListView to the radio group, I run into
> >> other issues, e.g. that some deep hierarchy java object cannot be
> >> serialized.
> >>
> >> This is really incorrect, but I'm unsure how to go about implementing
> >> radio boxes across item selections as in a ListView or RepeatingView.
> >>
> >> If it is really required to add the ListView or some such
> >> RepeatingView to the RadioGroup, it also express the other problem
> >> that if there are multiple radio groups say different fields in the
> >> rows, in which only one selection is valid for each field cannot be
> >> implemented. Because only a single ListView can be added to the
> >> RadioGroup, I'm not sure how to add the same ListView to 2 different
> >> RadioGroups.
> >>
> >> I'm not sure how to go about handling such needs.
> >>
> >> I think I need to rework my design.
> >>
> >> The use case is that there are multiple images in which they are
> >> listed in a listview, so that the user can select a particular image
> >> to delete, or set as the primary display image.
> >>
> >> But it seemed difficult to implement such a page /  form.
> >>
> >> On 31/07/2025 22:15, andrew goh wrote:
> >>>
> >>> it turns out the ListView need not be added to the RadioGroup, but
> >>> that when creating the Radio<> object, the radio group object needs
> >>> to be passed and that works just well.
> >>> so it looks like:
> >>>
> >>> public class MyObject {
> >>>   private Integer myInt;
> >>>   public void setMyInt(Integer myInt) ...
> >>>   public Integer getMyInt() ...
> >>> }
> >>> MyObject bean=new MyObject();
> >>> RadioGroup radioGroup = new RadioGroup("group", new
> >>> PropertyModel(bean, "myInt"));
> >>> add(radioGroup);
> >>>
> >>> List<Integer> items = new ArrayList<>();
> >>> items.add(1);
> >>> items.add(2);
> >>>
> >>> add(new ListView<Integer>("ListView", items) {
> >>>
> >>>     @Override
> >>>     protected void populateItem(ListItem<Integer> item) {
> >>>
> >>>         Integer value = item.getModelObject();
> >>>
> >>>         Radio<String> radio = new Radio<>("radio",
> >>> Model.of(Integer.toString(value)), radioGroup);
> >>>         item.add(radio);
> >>>
> >>>     }
> >>>
> >>> }
> >>>
> >>> <wicket:container wicket:id="group"></wicket:container>
> >>> <wicket:container wicket:id="ListView">
> >>>     <input type="radio" wicket:id="radio">
> >>> </wicket:container>
> >>>
> >>> If that is the case, multiple radio groups can be used, just pass
> >>> them (the radio group) when creating the Radio<> object.
> >>>
> >>> On 31/07/2025 20:29, andrew goh wrote:
> >>>>
> >>>> Recently I've a requirement that I need to have a radio button
> >>>> selection across multiple row items.
> >>>>
> >>>> I found some documentation for use of Radio and RadioGroups like this
> >>>>
> >>>> https://cwiki.apache.org/confluence/display/WICKET/Using+RadioGroups
> >>>> public class MyObject {
> >>>>   private Integer myInt;
> >>>>   public void setMyInt(Integer myInt) ...
> >>>>   public Integer getMyInt() ...
> >>>> }
> >>>>
> >>>> MyObject bean=new MyObject();
> >>>> RadioGroup myInt = new RadioGroup("group", new PropertyModel(bean,
> >>>> "myInt"));
> >>>> myInt.add(new Radio("1", new Model(1)));
> >>>> myInt.add(new Radio("2", new Model(2)));
> >>>> myInt.add(new Radio("3", new Model(3)));
> >>>> myInt.add(new Radio("4", new Model(4)));
> >>>> add(myInt);
> >>>>
> >>>>
> >>>> <span wicket:id="group">
> >>>>   <input wicket:id="1" type="radio"/>
> >>>>   <input wicket:id="2" type="radio"/>
> >>>>   <input wicket:id="3" type="radio"/>
> >>>>   <input wicket:id="4" type="radio"/>
> >>>> </span>
> >>>>
> >>>> However, this is for within the same (row) data item. While I
> >>>> worked things out it turns out that it is feasible to have radio
> >>>> items and radio  groups in a ListView.
> >>>> But that is is *tricky* like such:
> >>>>
> >>>> List<Integer> items = new ArrayList<>();
> >>>> items.add(1);
> >>>> items.add(2);
> >>>>
> >>>> MyObject bean=new MyObject();
> >>>> RadioGroup radioGroup = new RadioGroup("group", new
> >>>> PropertyModel(bean, "myInt"));
> >>>> add(radioGroup);
> >>>>
> >>>> radioGroup.add(new ListView<Integer>("ListView", items) {
> >>>>
> >>>>     @Override
> >>>>     protected void populateItem(ListItem<Integer> item) {
> >>>>
> >>>>         Integer value = item.getModelObject();
> >>>>
> >>>>         Radio<String> radio = new Radio<>("radio",
> >>>> Model.of(Integer.toString(value)), radioGroup);
> >>>>         item.add(radio);
> >>>>
> >>>>     }
> >>>>
> >>>> }
> >>>>
> >>>> <wicket:container wicket:id="group">
> >>>> <wicket:container wicket:id="ListView">
> >>>>     <input type="radio" wicket:id="radio">
> >>>> </wicket:container>
> >>>> </wicket:container>
> >>>>
> >>>> a few things, I think this could be useful to add in the documents
> >>>> as examples.
> >>>> the key is that the listview is added to the radio group !
> >>>>
> >>>> But that then I've a doubt / question.
> >>>>
> >>>> If you review docs for the html element radio e.g.
> >>>>
> >>>>
> https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/input/radio
> >>>>
> >>>> radio  groups is not specifically an element, radio groups are
> >>>> semantic in that <input type="radio"> elements forms a group
> >>>> if they  have the  same /name/ .
> >>>>
> >>>> Then my doubt is that if I've 2 distinct radio groups, in the same
> >>>> list view say one is for 'select' and another for 'default', I'm
> >>>> wondering how that can be achieved?
> >>>>
> >>>>
>


-- 
Regards -
Ernesto Reinaldo Barreiro
Apache Wicket Committer

Reply via email to