I think I have successfully untangled the ModelForm.java code.

The problem with the screen widget Java code is that most contributors and committers do not understand the architecture. This is probably due to the slight flaws in the architecture. My recent commits try to fix those flaws in ModelForm.java. I will make the same changes in other widget models.

Since the widget models contain rendering code, it is tempting to store rendering state in them. The problem is, the widget models are shared by many threads, so modifying the state in one thread changes the state for ALL threads.

Here is how I arranged things for the form widget:

ModelForm.java
--------------
A read-only data structure that represents the <form> XML element. It does not contain any behavior.

FormRenderer.java
-----------------
A rendering "engine" - calls the various FormStringRenderer methods in proper order.

Paginate.java
-------------
A utility class for managing list pagination. This is used by FormRenderer.java and the FormStringRenderer implementations.

I also included developer notes in the source code - so hopefully we won't have any more problems with developers breaking widget model thread-safety.


Adrian Crum
Sandglass Software
www.sandglass-software.com

On 11/2/2014 10:33 PM, Adrian Crum wrote:
Oh dear god. It's a good thing I'm going through this code.

ModelForm.java is badly broken. C&P errors in the constructor, plus
extended forms modify the state of the forms they extend.

Adrian Crum
Sandglass Software
www.sandglass-software.com

On 11/2/2014 2:12 PM, Adrian Crum wrote:
I started working on making the screen widgets thread-safe, but the
quantity of code was overwhelming.

So, I started reducing the widget code by reusing things, and by moving
the Artifact Info code to a separate class.

Screen widgets, form widgets, menu widgets, and tree widgets all share
the same actions now.

I discovered the Artifact Info feature has a lot of gaps, so the results
it produces are unreliable. The new classes in org.ofbiz.widget.artifact
can be build out to provide more complete information - if anyone is
interested in working on that.

One advantage to the new Artifact Info design is that it can be easily
extended to gather info on custom widgets.

I will update the widget schemas after I am done with the refactoring.

Reply via email to