Revision history [back]

click to hide/show revision 1
initial version

answered 2011-03-25 17:12:57 +0800

terrytornado gravatar image terrytornado flag of Germany

http://www.oxitec.de/

Hi Yogendra,

here is the extended code. You can download it in the zksample2 in customerListCtrl.java . Here is a pic.

Remember: A listitem holds a bean. Means you can get eventualy more values out of them as not in the listbox listcells is rendered.

     . . .
    // Test Popup on a listcell
    private Popup popup = null;
    private Label popLabel = null;
    private Vbox vbox = null;
    private Hbox titleBox = null;


        . . .

    /**
     * Test method for showing how to popup on a listcell.<br>
     * Extended. Now, it get the parent of the Listcell (a Listitem) and iterate through a list of
     * its listcells and show the value for each.
     * 
     * @param event
     */
    public void onMouseOverListCell(MouseEvent event) {

        // System.out.println("current target : " + event.getTarget());
        if (popup == null) {
            popup = new Popup();
            popup.setSclass("myPopup");
            popup.setParent(window_customerList);
            // popup.setWidth("200px");
            vbox = new Vbox();
            vbox.setStyle("padding: 0px;");
            vbox.setParent(popup);
            // clear old stuff
            vbox.getChildren().clear();
            titleBox = new Hbox();
            titleBox.setHeight("15px");
            titleBox.setWidth("100%");
            titleBox.setStyle("background-color: red;");
            titleBox.setParent(vbox);
            popLabel = new Label();
            popLabel.setParent(titleBox);
            popLabel.setValue("Customer Details");
            popLabel.setStyle("color: white; ");

        } else {
            // clear old stuff
            vbox.getChildren().clear();
            titleBox = new Hbox();
            titleBox.setHeight("15px");
            titleBox.setWidth("100%");
            titleBox.setStyle("background-color: red;");
            titleBox.setParent(vbox);
            popLabel = new Label();
            popLabel.setParent(titleBox);
            popLabel.setValue("Customer Details");
            popLabel.setStyle("color: white; ");
            popup.close();
        }

        Component comp = event.getTarget();

        if (comp instanceof Listcell) {

            System.out.println("1: " + comp.toString());
            System.out.println("2: " + ((Listcell) comp).getLabel().toString());
            System.out.println("3: " + comp.getParent().toString());

            // get the parent object of the listcell, should be a listitem
            Component parentComponent = comp.getParent();
            if (parentComponent instanceof Listitem) {

                // get a list of listcell that resides in the listItem
                List list = parentComponent.getChildren();

                // for all listcells we add a label with its value
                for (Object object : list) {
                    if (object instanceof Listcell) {
                        popLabel = new Label();
                        popLabel.setParent(vbox);
                        popLabel.setValue(((Listcell) object).getLabel().toString());
                    }

                }
            }

        }

        popup.open(window_customerList);

    }

pieces from the renderer

       . . .
    lc = new Listcell(customer.getKunOrt());
    lc.setParent(item);
    ComponentsCtrl.applyForward(lc, "onMouseOver=onMouseOverListCell");
      . . .

Can someone explain me why the setting of the StyleClass in java failed ?? Must i set a path to the css-file in the controller ? I will set the common padding to '0px' . --> popup.setSclass("myPopup");

piece of the zksample2.css

/* ------------------- Popup in Customerlist -------------------- */
 .myPopup .z-popup .z-popup-cm {
      padding: 0px;
      }

best Stephan

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More