0

How to customize a simlar component like Messagebox?

asked 2009-04-19 15:21:35 +0800

tianji gravatar image tianji
54 1

updated 2009-04-19 15:25:58 +0800

I want to customize the Messagebox component, that is to add names for buttons in archive/web/zul/html/messageboxdialog.zul.
but instead of modifying the origional source code, I desire to add new file named namedmessageboxdialog.zul
and in accordding to it, I desire to add an org.zkoss.zul.NamedMessageboxDlg.java.
Now I don't know what else to do, how to configure in conf files, can any guy tell me the steps in detail?

relative files are as bellow:
(1) archive/web/zul/html/namedmessageboxdialog.zul
<?xml version="1.0" encoding="UTF-8"?>
...
<hbox style="margin-left:auto; margin-right:auto">
<button id="btn1" name="aslmsgyes" identity="${arg.OK}" sclass="z-messagebox-btn" use="org.zkoss.zul.impl.MessageboxDlg$Button"
if="$"/>
<button name="aslmsgcancel" identity="${arg.CANCEL}" sclass="z-messagebox-btn" use="org.zkoss.zul.impl.MessageboxDlg$Button"
if="$"/>
...
</hbox>
</window>

(2) org.zkoss.zul.NamedMessageboxDlg.java
package org.zkoss.zul.impl;

...

/**
* Used with {@link Messagebox} to implement a message box.
*
* @author tomyeh
*/
public class MessageboxDlg extends Window {

...

/**
* Represents a button on the message box.
* @since 3.0.0
*/
public static class Button extends org.zkoss.zul.ASLNamedButton {
...
}
}

delete flag offensive retag edit

8 Replies

Sort by ยป oldest newest

answered 2009-04-20 03:22:01 +0800

hideokidd gravatar image hideokidd
750 1 2

updated 2009-04-20 03:22:25 +0800

Hi,

Configuration file would be src\archive\metainfo\zk\lang.xml
and component development guide may help
http://www.zkoss.org/doc/compdevguide/

link publish delete flag offensive edit

answered 2009-05-09 16:40:32 +0800

ibsolution gravatar image ibsolution
468 1 1 6

hai tiaji,

do use success to implement your Messagebox, Can you share that ?


Regards,

Andy Susanto

link publish delete flag offensive edit

answered 2009-05-10 20:21:16 +0800

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

@all

i have here posted code for a multiline-messagebox. Hope it can helps

Stephan

link publish delete flag offensive edit

answered 2009-05-15 06:56:22 +0800

ibsolution gravatar image ibsolution
468 1 1 6

updated 2009-05-15 07:00:14 +0800

hai Stephen,

i just try your code. The example almost work, but where is the button ?myCustomMessage


Regards,

Andy Susanto

link publish delete flag offensive edit

answered 2009-05-15 12:44:32 +0800

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

@ibsolution,

Please show your code.

Stephan

link publish delete flag offensive edit

answered 2009-05-15 16:50:06 +0800

ibsolution gravatar image ibsolution
468 1 1 6

hai,

zul file

<?xml version="1.0" encoding="UTF-8"?>
<window id="wndconfirm" use="org.zkoss.zul.impl.MessageboxDlg"
    title="${arg.title}" border="none" width="300pt" height="200pt">

    <hbox>
        <div class="${arg.icon}" />
        <div sclass="z-messagebox" width="100%">
            <label value="Password : " />
            <textbox id="pass" type="password" />
            
        </div>
    </hbox>

    <separator bar="true" />

    <hbox style="margin-left:auto; margin-right:auto">
        <button id="btn1" identity="${arg.OK}" sclass="z-messagebox-btn"
            use="org.zkoss.zul.impl.MessageboxDlg$Button" if="$" />
        <button identity="${arg.CANCEL}" sclass="z-messagebox-btn"
            use="org.zkoss.zul.impl.MessageboxDlg$Button" if="$" />
        <button identity="${arg.YES}" sclass="z-messagebox-btn"
            use="org.zkoss.zul.impl.MessageboxDlg$Button" if="$" />
        <button identity="${arg.NO}" sclass="z-messagebox-btn"
            use="org.zkoss.zul.impl.MessageboxDlg$Button" if="$" />
        <button identity="${arg.RETRY}" sclass="z-messagebox-btn"
            use="org.zkoss.zul.impl.MessageboxDlg$Button" if="$" />
        <button identity="${arg.ABORT}" sclass="z-messagebox-btn"
            use="org.zkoss.zul.impl.MessageboxDlg$Button" if="$" />
        <button identity="${arg.IGNORE}" sclass="z-messagebox-btn"
            use="org.zkoss.zul.impl.MessageboxDlg$Button" if="$" />
    </hbox>

</window>


java

toolBarBtn.addEventListener("onClick", new EventListener() {
				boolean canUpdate = Boolean.TRUE; 
				public void onEvent(Event event)
				{
					UserObject usrObj = (UserObject)(Sessions.getCurrent()).getAttribute("key");
					if (usrObj.doEditWithPassword()){
						canUpdate = !usrObj.doEditWithPassword();
						try{
							Messagebox.setTemplate("../windowconfirm/windowconfirm.zul");
							Messagebox.show("Insert Password to Edit", "Question", Messagebox.YES|Messagebox.NO,Messagebox.QUESTION,
									new EventListener() {

								public void onEvent(Event evt) {

									switch (((Integer)evt.getData()).intValue()) {

									case Messagebox.YES: canUpdate = Boolean.TRUE; break; //the Yes button is pressed

									case Messagebox.NO: canUpdate = Boolean.FALSE; break; //the No button is pressed

									}

								}});
						}catch(InterruptedException e1){}	
					}
					if (canUpdate){
						update(id);
					}
				}
			});

Regards,

Andy Susanto

link publish delete flag offensive edit

answered 2009-05-15 18:09:54 +0800

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

updated 2009-05-15 18:13:43 +0800

Hmmmm,

have a look at the original.

You have deleted the args of the if tags

if="$"

if="$ '{' '!' 'empty' 'arg''.'OK'}'"     --> Delete the ''. 

Argh. Cannot write the code here. It's time for made an update of the forum :-)


So the overhanded button-params are not evaluated.

This is originally by zkoss. I have only modified for multiline working.

Stephan

link publish delete flag offensive edit

answered 2009-05-16 01:08:57 +0800

ibsolution gravatar image ibsolution
468 1 1 6

oke,

i implement your code and now work properly

thanks for your help,

Andy Susanto

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-04-19 15:21:35 +0800

Seen: 697 times

Last updated: May 16 '09

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