0

treeitem onclick gets popup

asked 2009-12-21 06:50:17 +0800

jhuber gravatar image jhuber
192 1 4

Hey guys,

I generated a tree with java.

  /**
    * Applies the menu filter
    */
   public void filterMenus()
   {

      explorerGrid.setVisible(true);
      menuListbox.setHeight("24px");
      explorerTree.setVisible(true);
      Long regions = (Long)regionFilter.getSelectedItem().getValue();

      Long regionId = regions;

      MenuDMO[] menus = msUtils.getFilteredMenuDefinition(regionId);
      List<MenuInfoLine> lines = msUtils.getMenuInfoLinesFromMenus(menus);
      MenuDMO selectedMenu = getSelectedMenu();
      if (selectedMenu != null) {
         for (MenuInfoLine line : lines) {
            line.setSelected(line.getMenuId() == selectedMenu.getMenuId());
         }
      }
      setMenus(lines);
      reloadMenuDefinition();
      renderMenuItems();
      changeExportLink();
   }


   private void reloadMenuDefinitions()
   {
      AnnotateDataBinder binder = (AnnotateDataBinder)menuListbox.getVariable("binder", false);
      binder.loadAll();

   }


   /**
    * Returns the selected menuitem
    * 
    * @return the selected menuitem
    */
   private MenuitemDMO getSelectedMenuitem()
   {
      MenuitemDMO retval = null;

      Treeitem item = explorerTree.getSelectedItem();
      if (item != null) {
         retval = (MenuitemDMO)item.getValue();
      }
      return retval;

  <row
                                    style="border-width:0px 0px 0px 0px">
                                    <tree id="explorerTree"
                                       visible="false" zclass="z-dottree" sclass="ds-dottree"
                                       width="100%" fixedLayout="true" style="border:none;">
                                       <treecols
                                          sizable="false">
                                          <treecol
                                             label="Name" width="45%" />
                                          <treecol
                                             label="Von" />
                                          <treecol
                                             label="Bis" />
                                          <treecol
                                             align="center" label="Priorität" />
                                       </treecols>
                                    </tree>
                                 </row>
                              </rows>
                           </grid
>


Now I would like open a popup window by clicking on one item in tree.

How can I do this? Do I have to use java?

thanks for your replies...

delete flag offensive retag edit

7 Replies

Sort by » oldest newest

answered 2009-12-21 08:29:20 +0800

Rico gravatar image Rico
175 1 1 2

I have not tried this, but if You add an "onSelect" event to the tree, directing it to a java method (either in java or in a zscript). In this method You can get the selected item and then create/show a popup:

<zscript>
void onSelect()
{
  Treeitem item = tree.getSelectedItem();
  my_popup.open(item);
}
</zscript>

<popup id="my_popup">
  <label>Clicked!</label>
</popup>


...now this gives You a static popup, but You can of course change its content before showing it, or You can create a popup dynamically in the onSelect-method.

link publish delete flag offensive edit

answered 2009-12-21 08:39:20 +0800

jhuber gravatar image jhuber
192 1 4

thanks for the quick answer... i will try it :)

link publish delete flag offensive edit

answered 2009-12-21 09:11:01 +0800

jhuber gravatar image jhuber
192 1 4

It's not working, because the method can't find the id of the popup.
I built the popup with java:

private void openModalWindow(String zulName) {
      HashMap<String, Object> map = new HashMap<String, Object>();
      Window win = (Window)Executions.createComponents(zulName, this, map);
      ZkUtils.setWindowModal(win);
   }

   public void openNewProjectPopup() {
      openModalWindow("ProjectNew.zul");
   }

I think the problem is, because the popup is in a different zul file...

so what can I do now ???

link publish delete flag offensive edit

answered 2009-12-21 18:46:34 +0800

samchuang gravatar image samchuang
4084 4

Hi ~~

I am thinking, you have a popup zul file, so you could use apply a composer in the popup zul file, is this workable in your case??

link publish delete flag offensive edit

answered 2009-12-22 00:58:36 +0800

Rico gravatar image Rico
175 1 1 2

I am not really sure what You want to accomplish here. As I interpret Your code, You do not use a zk-Popup but rather a standard window that You want to show as a modal window?

This should work too, of course, but not what I expected You to be after.

What does Your ProjectNew.zul look like?

link publish delete flag offensive edit

answered 2009-12-22 01:32:35 +0800

jhuber gravatar image jhuber
192 1 4

updated 2009-12-22 04:05:37 +0800

@samchuang:
Sorry... I don't unerstand you...
I' using this in window: use="de.home.dip.MC" in the MC.zul
So you mean maybe if I'm doing the same in ProjectNew.zul it'll work ?

never used apply in the window...

@ Rico
yes that's exactly what I mean my popup Window schouldn't look like normal zk-popup

This popup is already working with menubar
MC.zul :

....
<menubar id="menubar" width="100%"
                              style="border:'none'">
                              <menu label="Projekt"
                                 src="images/document.png">
                                 <menupopup>
                                    <menuitem label="Neu"
                                       onClick="MC.openNewProjectPopup()"
                                       src="images/neu.png"/>
.....

this is my ProjectNew.zul :

<?page title="ProjectNew" contentType="text/html;charset=UTF-8"?>
<?init class="org.zkoss.zkplus.databind.AnnotateDataBinderInit" arg0="./NeuesProjekt"?>

<zk>
   <window id="NeuesProjekt" title="Neues Projekt" border="normal"
      closable="true" width="400px" sizable="true" shadow="none">

      <tabbox>
         <tabs>
            <tab label="test1" />
            <tab label="test2" />
         </tabs>
         <tabpanels>
            <tabpanel>
               <hbox>
                  <div width="10px" />
                  <vbox>
                     <div height="40px" />
                     <hbox>
                        <div width="150px" height="40px">
                           <label value="Projekt1" />
                        </div>
                        <textbox width="150px" />
                     </hbox>
                     <hbox>
                        <div width="150px" height="40px">
                           <label value="Projekt2" />
                        </div>
                        <datebox width="133px" />
                     </hbox>
                     <hbox>
                        <div width="150px" height="40px">
                           <label value="Projekt3" />
                        </div>
                        <datebox width="133px" />
                     </hbox>
                     <hbox>
                        <div width="150px" height="40px">
                           <label value="Projekt4r" />
                        </div>
                        <textbox />
                     </hbox>
                     <hbox>
                        <div width="150px" height="40px">
                           <label value="Projekt5" />
                        </div>
                        <checkbox label="hoch"
                           onCheck="doChecked()" />
                        <checkbox label="mittel"
                           onCheck="doChecked()" />
                        <checkbox label="gering"
                           onCheck="doChecked()" />
                     </hbox>
                     <hbox>
                        <div width="150px" height="40px">
                           <label value="Projekt6" />
                        </div>
                        <textbox height="100px" multiline="true"
                           width="150px" />
                     </hbox>
                     <div height="40px" />
                  </vbox>
               </hbox>
            </tabpanel>
            <tabpanel>
               <hbox>
                  <div width="10px" />
                  <vbox>
                     <div height="40px" />
                     <hbox>
                        <div width="150px" height="40px">
                           <label value="Projekt1" />
                        </div>
                        <textbox width="150px" />
                     </hbox>
                     <hbox>
                        <div width="150px" height="40px">
                           <label value="Projekt2t" />
                        </div>
                        <textbox width="150px" />
                     </hbox>
                     <hbox>
                        <div width="150px" height="40px">
                           <label value="Projekt3" />
                        </div>
                        <textbox width="150px" />
                     </hbox>
                     <hbox>
                        <div width="150px" height="40px">
                           <label value="Projekt4" />
                        </div>
                        <vbox>
                           <checkbox
                              label="noch nicht gestartet" onCheck="doChecked()" />
                           <checkbox label="in Bearbeitung"
                              onCheck="doChecked()" />
                           <checkbox label="angehalten"
                              onCheck="doChecked()" />
                           <checkbox label="hinter Zeitrahmen"
                              onCheck="doChecked()" />
                           <checkbox label="fertig gestellt"
                              onCheck="doChecked()" />
                        </vbox>
                     </hbox>
                     <div height="40px" />
                  </vbox>
               </hbox>
            </tabpanel>
         </tabpanels>
      </tabbox>
      <toolbar height="40px" mold="panel" align="center">
         <button label="Abbrechen" style="align:center" width="50px" />
         <button label="Projekt hinzufügen" style="align:center"
            width="50px" />
      </toolbar>

   </window>
</zk>

link publish delete flag offensive edit

answered 2009-12-22 17:31:10 +0800

terrytornado gravatar image terrytornado flag of Germany
9393 3 7 16
http://www.oxitec.de/

I know i have read about such a thing here in the forum. I found it !

So, only a hint!

you must give the menupopup a parent in this zul
because it not exist this zul page if you not set a parent for it

Here is the thread.

best
Stephan

link publish delete flag offensive edit
Your reply
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow

RSS

Stats

Asked: 2009-12-21 06:50:17 +0800

Seen: 1,082 times

Last updated: Dec 22 '09

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