ZK Disbale Div, Window, Layout Component?

I am using the ZK Framework in my project. I have many other components inside a div or Window component. Can someone tell me how I can disable a component Divor Windowin a specific condition. As I tested, there is no attribute for these components disable.

Any other way: I disablea Divor Windowotherwise I have to disable every component inside Divor WindoworLayout

+1
source share
3 answers

Here is a very simple way to disable all components that implement Disable.

@Wire("disable")
private List<Disable> allToDisable;

private disableAll(List<Disable> list){
   for(Disable d : list){
       d.setDisabled(true);
   }
}

@Wire ,
Selectors
zk. "disable", , .

+2

Gatekeeper (16 13: 9 9:22), "if". if (ac instanceof Disable) {--- code -}

public static void disableComponents( AbstractComponent pComponent ) {
    for( Object o : pComponent.getChildren() ) {
        AbstractComponent ac = ( AbstractComponent ) o;
        try {
            if (ac instanceof Disable) {
                Method m = ac.getClass().getMethod("setDisabled", Boolean.TYPE);
                m.invoke(ac, true);
            }
        } catch( Exception e ) {
            e.printStackTrace();
        }

        List children = ac.getChildren();
        if( children != null ) {
            disableComponents( ac );
        }
    }
}
+3

, , - ( google, , - )

public static void disableComponents( AbstractComponent pComponent ) {

  for( Object o : pComponent.getChildren() ) {

     AbstractComponent ac = ( AbstractComponent ) o;

     try {
        Method m = ac.getClass().getMethod( "setDisabled", Boolean.TYPE );
        m.invoke( ac, true );
     } catch( Exception e ) {
     }

     List children = ac.getChildren();
     if( children != null ) {
        disableComponents( ac );
     }
  }

}

+2

Source: https://habr.com/ru/post/1619177/


All Articles