Uploaded image for project: 'ZK'
  1. ZK
  2. ZK-3144

simplify switching between flex and fixed width

XMLWordPrintable

    • Icon: New Feature New Feature
    • Resolution: Fixed
    • Icon: Normal Normal
    • 8.0.3
    • 8.0.1.1
    • Components
    • Security Level: Jimmy
    • ZK 8.0.3 S1

      since ZK 8 simultaneos usage of h/vflex and fixed height/width has been restricted -> OK

      however the current implementation makes it diffcult to reset height/width without additional checks or workarounds.

      The attachment shows a simple scenario with 2 buttons to switch between a flex and a fixed width. When clicking a button twice it will lead to an exception even if the intermedate results never violate the flex vs fixed constraint

      The idea is to reset hflex to NULL before setting a width, and vice versa.
      However when hflex is already NULL and a width exists a call to setHflex(null) causes an exception, even if it does not lead to an illegal state. Instead the developer has to perform tedious IF-checks everytime when trying to set a component to either flex or fixed width.

      to set a fixed width:

      //reset width before attempting to reset hflex
      if(comp.getWidth() != null) { //need to check first in case hflex exists
        comp.setWidth(null);
      }
      comp.setHflex(null); //this would cause an unnecessary exception if width still existed
      comp.setWidth("300px")
      

      when allowing to always set NULL values those checks become unnecessary

        comp.setHflex(null); //if NULL always allowed -> no prior check necessary
        comp.setWidth("300px")
      

      and for the opposite way the same principle

        comp.setWidth(null);
        comp.setHflex("1");
      

      A proposed solution to allow NULL values is to apply this pattern in setH/Vflex and setHeight/Width

      public void setVflex(String flex) {
         if (getHeight() != null && !(flex == null || "min".equals(flex)) { //allow null here
             throw new UiException("Not allowed to set vflex and height at the same time except vflex=\"min\"");
             }
          setVflex0(flex);
      }
      

            wenninghsu wenninghsu
            cor3000 cor3000
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved:

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 2 hours
                2h