0

pass variable values to popup window

asked 2013-07-19 11:19:13 +0800

demizon gravatar image demizon
179 1 6

updated 2013-07-22 08:54:20 +0800

Hi, i got problem with popup window. I tried to make simple application but popup window doesnt work properly. When i enter name of hanresstype into textbox and press ok, it should get object harnesstype and show its attributes in popup window. Problem is, it just get object harnesstype, but it doesn t send it to the popupwindow or doesnt update popupwindow.

my zul file:

<groupbox title="Tlac etikiet" closable="false" apply="org.zkoss.bind.BindComposer"
          viewModel="@id('vm') @init('com.leoni.emo.general.modelViews.GeneratorViewModel')">

    <grid width="700px">
        <rows>

            <row popup="detail_${harnesstype.id}, position=end_before" style="cursor:pointer">
                <div>
                                        <popup id="detail_${harnesstype.id}">
                                            <include src="/harnesstype_detail.zul"
                                            harnesstype="${harnesstype}"/>
                                        </popup>
                </div>
                Harnesstype name:
                <textbox value="@bind(vm.harnesstypeAliasName)" onOK="@command('getCount')" focus="@load(vm.focus1)" disabled="@load(vm.disabled)"/>
            </row>
        </rows>
    </grid>

</groupbox>

popupwindow zul:

<vlayout width="300px">
    <label value="${harnesstype.id}" style="font-size: 14px; font-weight: bold;" />
    <grid>
        <rows>
            <row>
                Name:
                <label value="${harnesstype.id}" />
            </row>


        </rows>
    </grid>
</vlayout>
delete flag offensive retag edit

Comments

Have a viewmodel for popupwindow.zul, Now in your viewmodel ---> aftercompose method do like:

@Aftecompose
public void doAfterCompose(@ExecutionParam("harnesstype") object harnesstype){
}

rest is the same as we do for all zul file.

nsharma ( 2013-07-22 10:27:56 +0800 )edit

3 Answers

Sort by ยป oldest newest most voted
0

answered 2013-07-24 12:39:52 +0800

sjoshi gravatar image sjoshi flag of India
3493 1 8
http://zkframeworkhint.bl...

updated 2013-07-29 10:34:38 +0800

When you press the OK Button write logic in that button to open your modal Window and do something like this..

@Command
public void oKButtonPress(@ContextParam(ContextType.VIEW) Component comp) {
        Harnesstype harnesstype =  //Your Business Logic to get the object
        showModalWindow(harnesstype,comp );
             }

And here the logic to create Modal Window and pass the Object in same viewModel or Parent ZUL.

  public void showModalWindow(Harnesstype harnesstype,Component comp) {
            Map<String, String> arguments = new HashMap<String, String>();
            arguments.put("harnesstype", harnesstype);
              Executions.createComponents("popupwindow.zul", comp, arguments);

        }

And now in afterCompose of your PopupModalWindow Java class write this logic..

 public void doAfterCompose(@ContextParam(ContextType.VIEW) Component view,
                 @ExecutionArgParam("harnesstype") Harnesstype myObject) throws Exception {
            //Now do what you want to do with Harnesstype  object.
        }

See this will help you .

And in you zul do this

<window apply="org.zkoss.bind.BindComposer"  viewModel="@id('vm') @init('com.YourViewModel')" height="50%" width="48%" mode="modal" >

See i added mode="modal" attribute and deleted from java code

link publish delete flag offensive edit

Comments

Yes for opening Your popup zul you have to do like as @sjoshi suggests,but as you haven't used "window" as your parent element Add win.doPopup(); instead of win.doModel(); ,but if u will use "window " as parent ,just add mold="modal" in your window component,it will be called as a popup everytime

nsharma ( 2013-07-25 05:28:12 +0800 )edit
0

answered 2013-07-24 08:59:23 +0800

demizon gravatar image demizon
179 1 6

updated 2013-07-24 09:30:02 +0800

i dont know if i understand you right... i changed popupwindow.zul to:

<groupbox title="Test popup"  apply="org.zkoss.bind.BindComposer"
          viewModel="@id('vm') @init('com.leoni.emo.general.modelViews.PopupViewModel')">
<vlayout width="300px">
    <label value="${harnesstype.id}" style="font-size: 14px; font-weight: bold;" />
    <grid>
        <rows>
            <row>
                Name:
                <label value="${harnesstype.id}" />
            </row>

        </rows>
    </grid>
</vlayout>
</groupbox>

and created PopupViewModel:

package com.leoni.emo.general.modelViews;

import com.leoni.emo.general.entity.Harnesstype;
import org.zkoss.bind.annotation.AfterCompose;
import org.zkoss.bind.annotation.ExecutionParam;


    public class PopupViewModel {


        @AfterCompose
        public void doAfterCompose(@ExecutionParam("harnesstype") Harnesstype harnesstype){

        }
    }

is this all i have to do? because its still not working

link publish delete flag offensive edit
0

answered 2013-07-26 09:14:10 +0800

demizon gravatar image demizon
179 1 6

updated 2013-07-29 09:55:29 +0800

sjoshi gravatar image sjoshi flag of India
3493 1 8
http://zkframeworkhint.bl...

i updated my app, but its still not working, i cant get object harnesstype to popupwindow....

my popupwindow.zul

<window title="Test popup"  apply="org.zkoss.bind.BindComposer"
          viewModel="@id('vm') @init('com.leoni.emo.general.modelViews.PopupViewModel')">
<vlayout width="300px">
    <label value="${harnesstype.id}" style="font-size: 14px; font-weight: bold;" />
    <grid>
        <rows>
            <row>
                Name:
                <label value="${harnesstype.id}" />
            </row>
            <row>
                            Alias:
                            <label value="${harnesstype.aliasname}" />
                        </row>

        </rows>
    </grid>
</vlayout>
</window>

part of generatorviewmodel (parent):

@Command

    public void getCount(@ContextParam(ContextType.VIEW) Component comp) {


        harnesstype=jobOrderControllerImpl.getHarnesstypeByAliasName(harnesstypeAliasName);
            showModalWindow(harnesstype,comp);

    }


public void showModalWindow(Harnesstype harnesstype,Component comp) {
        Map<String, Harnesstype> arguments = new HashMap<String, Harnesstype>();
        arguments.put("harnesstype", harnesstype);
        Window win = (Window) Executions.createComponents("/harnesstype_detail.zul", comp, arguments);
        win.doPopup();
    }

popupwindowviewmodel:

package com.leoni.emo.general.modelViews;
import com.leoni.emo.general.entity.Harnesstype;
import org.zkoss.bind.annotation.*;

public class PopupViewModel {
Harnesstype harnesstype;
    public void setHarnesstype(Harnesstype harnesstype) {
        this.harnesstype = harnesstype;
    }
    public Harnesstype getHarnesstype() {
        return harnesstype;
    }
    public void doAfterCompose(@ContextParam(ContextType.VIEW) Component view,
                               @ExecutionArgParam("harnesstype") Harnesstype myObject) throws Exception {
        harnesstype=myObject;
    }
}
link publish delete flag offensive edit

Comments

Where is your showModalWindow(harnesstype); code?

sjoshi ( 2013-07-26 10:53:27 +0800 )edit

oh, sry...edited my post

demizon ( 2013-07-26 11:08:12 +0800 )edit

@afterCompose is missing from PopupViewModel.java class

sjoshi ( 2013-07-26 14:09:56 +0800 )edit

added, now I m getting following error: class org.zkoss.zul.Window cant be converted to class java.awt.Component.

demizon ( 2013-07-29 06:10:08 +0800 )edit

delete this @ContextParam(ContextType.VIEW) Component view, and try

sjoshi ( 2013-07-29 07:30:07 +0800 )edit
Your answer
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
1 follower

RSS

Stats

Asked: 2013-07-19 11:19:13 +0800

Seen: 193 times

Last updated: Jul 29 '13

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