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

Databinding using RadiogroupSelectedItemConverter does not work if Radio buttons are not children of Radiogroup

    XMLWordPrintable

    Details

      Description

      This code is better for org.zkoss.zkplus.databind.RadiogroupSelectedItemConverter:
      public Object coerceToUi(Object val, Component comp) {
      if (val != null && comp instanceof Radiogroup) {
      Radiogroup rg = (Radiogroup) comp;
      // iterate to find the selected radio via the value
      for (Iterator<Radio> it = rg.getItems().iterator(); it.hasNext() {
      Radio child = it.next();
      if (val.equals(((Radio) child).getValue()))

      { return child; }

      }
      }
      return null;
      }

      Feel free to add this simple snippet to ZK.

        Attachments

          Activity

            People

            Assignee:
            danchen0720 danchen0720
            Reporter:
            chemFelix chemFelix
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: