While I'm learning the ropes of Apache Wicket currently and I'm
exploring making reusable components.
I tried making An Apache Wicket reusable Data List
This component displays a list of JavaBeans as a html table
DataListPanel takes as input in the constructor :
the wicket:id of the component
itemclass The java class of the JavaBean
List items the list of JavaBeans
https://gist.github.com/ag88/a0232510c28b4c45b82943527b7ea87e
This version is pretty rough as I'm trying out a 'proof of concept' test.
it actually works, rendering the list of JavaBeans as a html table.
I used an often 'neglected' java package java.beans, technology Javabeans
https://en.wikipedia.org/wiki/JavaBeans
https://download.oracle.com/otndocs/jcp/7224-javabeans-1.01-fr-spec-oth-JSpec/
practically as 'old' as Java itself.
It is probably quite interesting as many database interfaces basically
use JavaBeans to represent the records and as well used in forms.
This practically makes the task of displaying records in a (html) table
done using a reusable component.
It is likely possible to implement similar setup say with
spring-framework, spring-boot and templates, but that Apache Wicket
makes the codes and templates very concise.
The magic is implemented by the repeating views
https://nightlies.apache.org/wicket/guide/9.x/single.html#_the_repeatingview_component
and java.beans itself which I get the 'field' (beaninfo) names and java
reflection retrieval.
I think it is likely feasible to implement such reusable pages as form
components too, i.e. give a form a JavaBean it renders it and
handles/process it with database CRUD and all.
Cheers,
Andrew