2020import org .zkoss .zk .ui .Component ;
2121import org .zkoss .zk .ui .HtmlBasedComponent ;
2222import org .zkoss .zk .ui .event .Events ;
23- import org .zkoss .zul .Button ;
24- import org .zkoss .zul .Decimalbox ;
25- import org .zkoss .zul .Div ;
26- import org .zkoss .zul .Doublebox ;
27- import org .zkoss .zul .Label ;
28- import org .zkoss .zul .Textbox ;
29- import org .zkoss .zul .Vbox ;
30- import org .zkoss .zul .Window ;
23+ import org .zkoss .zul .*;
3124import tools .dynamia .commons .ObjectOperations ;
3225import tools .dynamia .commons .logger .Loggable ;
33- import tools .dynamia .integration .Containers ;
34- import tools .dynamia .viewers .ComponentCustomizer ;
3526import tools .dynamia .viewers .Field ;
36- import tools .dynamia .viewers .FieldCustomizer ;
3727import tools .dynamia .viewers .util .ComponentCustomizerUtil ;
28+ import tools .dynamia .viewers .util .Viewers ;
3829import tools .dynamia .web .util .HttpUtils ;
3930import tools .dynamia .zk .util .ZKBindingUtil ;
4031import tools .dynamia .zk .util .ZKUtil ;
4132
42- import java .util . Collection ;
33+ import java .io . Serial ;
4334
4435@ SuppressWarnings ("rawtypes" )
4536public class InputPanel extends Div implements Loggable {
4637
4738 public static final String ON_INPUT = "onInput" ;
39+ @ Serial
4840 private static final long serialVersionUID = 7388726856898185544L ;
41+ public static final String BINDING_ATTRIBUTE = "bindingAttribute" ;
4942
5043 private HtmlBasedComponent textbox ;
5144 private Label label ;
5245 private Button okButton ;
5346 private Object value ;
5447 private final Class inputClass ;
48+ private Field inputField ;
5549
5650 public InputPanel () {
5751 this (null , null , String .class );
@@ -70,9 +64,10 @@ public InputPanel(String label, Object value, Class inputClass) {
7064 this .value = value ;
7165 renderView (label );
7266
67+ String bindingAttribute = inputField != null && inputField .getParam (BINDING_ATTRIBUTE ) != null ? inputField .getParam (BINDING_ATTRIBUTE ).toString () : null ;
7368 Binder binder = ZKBindingUtil .createBinder ();
7469 ZKBindingUtil .initBinder (binder , this , this );
75- ZKBindingUtil .bindComponent (binder , textbox , "inputPanel.value" , null );
70+ ZKBindingUtil .bindComponent (binder , textbox , bindingAttribute , "inputPanel.value" , null );
7671 ZKBindingUtil .bindBean (this , "inputPanel" , this );
7772 binder .loadComponent (this , false );
7873 addListeners ();
@@ -127,29 +122,24 @@ private void renderView(String label) {
127122 private Component buildTextbox () {
128123 Class componClass = null ;
129124
130- Field field = new Field ("field" , inputClass );
131- Collection <FieldCustomizer > customizers = Containers .get ().findObjects (FieldCustomizer .class );
132- if (customizers != null ) {
133- for (FieldCustomizer fieldCustomizer : customizers ) {
134- fieldCustomizer .customize ("form" , field );
135- }
136- }
125+ inputField = new Field ("field" , inputClass );
126+ Viewers .customizeField ("form" , inputField );
137127
138- if (field .getComponentClass () != null ) {
139- componClass = field .getComponentClass ();
128+ if (inputField .getComponentClass () != null ) {
129+ componClass = inputField .getComponentClass ();
140130 } else {
141131 componClass = Textbox .class ;
142132 }
143133
144134 Component comp = (Component ) ObjectOperations .newInstance (componClass );
145- if (field .getComponentCustomizer () != null ) {
135+ if (inputField .getComponentCustomizer () != null ) {
146136 try {
147- ComponentCustomizerUtil .customizeComponent (field , comp , field .getComponentCustomizer ());
137+ ComponentCustomizerUtil .customizeComponent (inputField , comp , inputField .getComponentCustomizer ());
148138 } catch (Exception e ) {
149139 log ("Cannot create component customizer" , e );
150140 }
151141 }
152- ObjectOperations .setupBean (comp , field .getParams ());
142+ ObjectOperations .setupBean (comp , inputField .getParams ());
153143 return comp ;
154144 }
155145
0 commit comments