-
FEATURED COMPONENTS
First time here? Check out the FAQ!
How can we use new line in Messagebox?
I'll post this evening a sample for a multiline messagebox that i use.
regards
Stephan
Hi kkurt,
attached my multiLineMessageBox. It works with Labels.getLabel() for
internationalization.
MultiLineMessagebox.java
package org.myfirm.webui.util; import org.zkoss.zul.Messagebox; public class MultiLineMessageBox extends Messagebox { private static final long serialVersionUID = -4855008103857120664L; private static String _templ = "/WEB-INF/pages/util/multiLineMessageBox.zul"; public MultiLineMessageBox() { } public static void doSetTemplate() { setTemplate(_templ); } /** * Shows a message box and returns what button is pressed. A shortcut to * show(message, null, OK, INFORMATION). <br> * <br> * Simple MessageBox with customizable message and title. <br> * * @param message * The message to display * @param title * The title to display * @return * @throws InterruptedException */ public static final int show(String message, String title) throws InterruptedException { return show(message, title, OK, INFORMATION, 0, null); } }
MultiLinemessageBox.zul
<?xml version="1.0" encoding="UTF-8"?> <?page title="Multiline Messagebox" language="xul/html"?> <window title="${arg.title}" border="none" width="300pt" closable="true" use="org.zkoss.zul.impl.MessageboxDlg"> <hbox> <div class="${arg.icon}" /> <div sclass="z-messagebox" width="100%"> <label multiline="true" value="${arg.message}" sclass="word-wrap" width="100%" /> </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>
Sample call:
... // set the message and title String msg = Labels.getLabel("message_Data_Modified_Save_Data_YesNo"); String title = Labels.getLabel("message_Information"); MultiLineMessageBox.doSetTemplate(); // Same call like the normal MessageBox if (MultiLineMessageBox.show(msg, title, Messagebox.YES | Messagebox.NO, Messagebox.QUESTION, new EventListener() { public void onEvent(Event evt) { ...
i3-label.properties
message.question.are_you_sure_to_delete_this_record={ Hi guys, are you sure to delete this record ? }
regards
Stephan
Thanks Terry for sharing this code...
Asked: 2009-04-17 12:28:50 +0800
Seen: 716 times
Last updated: Apr 20 '09