ControlFX Action Usage - javafx-8

I have an application with both MenuBar and ToolBar. I found in ControlsFX documentation that it is possible to define the action event logic in a different class and assign it to buttons, menuitems and togglebuttons define by fxml. More or less like a router in php frameworks(e.g laravel).
Here is the description
An action in JavaFX can be used to separate functionality and state from a control. For example, if you have two or more controls that perform the same function (e.g. one in a Menu and another on a toolbar), consider using an Action object to implement the function. An Action object provides centralized handling of the state of action-event-firing components such as buttons, menu items, etc. The state that an action can handle includes text, graphic, long text (i.e. tooltip text), and disabled.
The problem is that i was not able to get enough info to use it in my application. Here is a simple example i have so far
public class RootController implements Initializable {
#FXML
private MenuItem menuOne;
#FXML
private MenuItem menuTwo;
#FXML
private MenuItem menuThree;
#FXML
private Button tbOne;
#FXML
private Button tbTwo;
#FXML
private Button tbThree;
#Override
public void initialize(URL url, ResourceBundle rb) {
// TODO
}
}
root.fxml
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.scene.control.Button?>
<?import javafx.scene.control.Menu?>
<?import javafx.scene.control.MenuBar?>
<?import javafx.scene.control.MenuItem?>
<?import javafx.scene.control.ToolBar?>
<?import javafx.scene.layout.BorderPane?>
<?import javafx.scene.layout.VBox?>
<BorderPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/8.0.65" xmlns:fx="http://javafx.com/fxml/1">
<top>
<VBox BorderPane.alignment="CENTER">
<children>
<MenuBar>
<menus>
<Menu mnemonicParsing="false" text="File">
<items>
<MenuItem fx:id="menuOne" mnemonicParsing="false" text="One" />
</items>
</Menu>
<Menu mnemonicParsing="false" text="Edit">
<items>
<MenuItem fx:id="menuTwo" mnemonicParsing="false" text="Two" />
</items>
</Menu>
<Menu mnemonicParsing="false" text="Whatever">
<items>
<MenuItem fx:id="menuThree" mnemonicParsing="false" text="Three" />
</items>
</Menu>
</menus>
</MenuBar>
<ToolBar prefHeight="40.0" prefWidth="200.0">
<items>
<Button fx:id="tbOne" mnemonicParsing="false" text="One" />
<Button fx:id="tbTwo" layoutX="10.0" layoutY="13.0" mnemonicParsing="false" text="Two" />
<Button fx:id="tbThree" layoutX="66.0" layoutY="13.0" mnemonicParsing="false" text="Three" />
</items>
</ToolBar>
</children>
</VBox>
</top>
</BorderPane>
Main
public class MainApp extends Application {
public static void main(String[] args) throws Exception {launch(args); }
public void start(Stage stage) throws Exception {
FXMLLoader loader = new FXMLLoader(getClass().getResource("/fxml/root.fxml"));
loader.setController(new RootController());
Scene scene = new Scene((Parent)loader.load(), 400, 200);
stage.setTitle("ControlFX Action API");
stage.setScene(scene);
stage.show();
}
}
AppRouter
public class AppRouter {
public AppRouter(){
ActionMap.register(this);
}
public void testOne(){
System.out.println("testOne");
}
public void testTwo(){
System.out.println("testTwo");
}
public void testThree(){
System.out.println("testThree");
}
}
My problem is how to assign the methods in AppRouter to buttons and menuitems in the RootController
Update
I will gladly accept anyother alternative answer too.

Let's assume that you will create an Instance of AppRouter class in
the Application class:
public class MainApp extends Application {
AppRouter appRouter = new AppRouter(); //here................
public static void main(String[] args) throws Exception {launch(args); }
public void start(Stage stage) throws Exception {
FXMLLoader loader = new FXMLLoader(getClass().getResource("/fxml/root.fxml"));
loader.setController(new RootController());
Scene scene = new Scene((Parent)loader.load(), 400, 200);
stage.setTitle("ControlFX Action API");
stage.setScene(scene);
stage.show();
}
}
Then you can have a method which accepts an AppRouter,in the
FXMLController:
public class RootController implements Initializable {
#FXML
private MenuItem menuOne;
#FXML
private MenuItem menuTwo;
#FXML
private MenuItem menuThree;
#FXML
private Button tbOne;
#FXML
private Button tbTwo;
#FXML
private Button tbThree;
#Override
public void initialize(URL url, ResourceBundle rb) {
// TODO
}
public void acceptRouter(AppRouter router){
//register or call router methods here
}
}
How to get the controller you just created into the MainApp class?
FXMLLoader loader = new FXMLLoader(getClass().getResource("/fxml/root.fxml"));
loader.setController(new RootController());
RootController controller = loader.getController(); //simple as this,although check the method name if it is the same cause i added this from phone
controller.acceptRouter(appRouter);

Related

NET MAUI how to create a hamburger menu

I am trying to create a hamburger menu in xaml, but zero success. I was trying to use the samples provided [here][1], but zero success.
My idea is to create a view model that has a list of FlyoutItems then inject this view model to the AppShell.
public partial class ShellViewModel : ObservableObject
{
public List<FlyoutItem> FlyoutItems { get; private set; } = new List<FlyoutItem>();
public ShellViewModel()
{
AddMenuItems();
}
private void AddMenuItems()
{
var flyoutItems = new List<FlyoutItem>
{
new FlyoutItem
{
Title = "Item 1"
},
new FlyoutItem
{
Title = "Item 2"
}
};
FlyoutItems.AddRange(flyoutItems);
}
}
public partial class AppShell : Shell
{
private ShellViewModel viewModel => BindingContext as ShellViewModel;
public AppShell(ShellViewModel viewModel)
{
BindingContext = viewModel;
RegisterRoutes();
InitializeComponent();
}
private void RegisterRoutes()
{
Routing.RegisterRoute(PageRoutes.LoginPage, typeof(LoginPage));
Routing.RegisterRoute(PageRoutes.RegisterPage, typeof(RegisterPage));
Routing.RegisterRoute(PageRoutes.HomePage, typeof(MainPage));
Routing.RegisterRoute(PageRoutes.DetailsPage, typeof(PlayerDetailsPage));
Routing.RegisterRoute(PageRoutes.AddOrUpdatePage, typeof(AddOrUpdatePlayer));
}
}
In the XAML sometign like this
<?xml version="1.0" encoding="UTF-8" ?>
<Shell
x:Class="MauiUI.AppShell"
xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:MauiUI"
xmlns:pages="clr-namespace:MauiUI.Pages">
<Shell.ItemTemplate>
<DataTemplate>
<CollectionView BindingContext="{x:Reference shell}"
IsGrouped="True"
ItemsSource="{Binding FlyoutItems}">
<CollectionView.ItemTemplate>
<DataTemplate>
<Label Text="{Binding Title}"
TextColor="White"
FontSize="18" />
</DataTemplate>
</CollectionView.ItemTemplate>
</CollectionView>
</DataTemplate>
</Shell.ItemTemplate>
<ShellContent
Title="Amazons of Volleyball"
ContentTemplate="{DataTemplate pages:SplashPage}"
Route="HomePage" />
</Shell>
thnx
[1]: https://learn.microsoft.com/en-us/dotnet/maui/fundamentals/shell/flyout?view=net-maui-7.0
I am trying to create a hamburger menu in xaml, but zero success.
You can add this code in your AppShell.xaml:
<?xml version="1.0" encoding="UTF-8" ?>
<Shell
x:Class="MauiUI.AppShell"
xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:MauiUI"
xmlns:views="clr-namespace:MauiUI.Pages">
<FlyoutItem FlyoutDisplayOptions="AsMultipleItems">
<ShellContent Title="Home"
Route="home"
ContentTemplate="{DataTemplate local:MainPage}" />
<ShellContent Title="NewPage1"
ContentTemplate="{DataTemplate pages:NewPage1}" />
</FlyoutItem>
</Shell>
Or you can add this code in your AppShell.xaml.cs:
public partial class AppShell : Shell    
{
  public AppShell ()        
{
        InitializeComponent ();
        
        FlyoutItem flyoutItem = new FlyoutItem ();
        flyoutItem.FlyoutDisplayOptions = FlyoutDisplayOptions.AsMultipleItems;
        
        flyoutItem.Items.Add (new ShellContent () { Title = "NewPage1", Content = new NewPage1 () });
        flyoutItem.Items.Add (new ShellContent () { Title = "home", Content = new MainPage () });
        
        myshell.Items.Add (flyoutItem);
        
}
    
}

Trying to display a popup gives "The Parent must be of type Microsoft.Maui.Handlers.PageHandler."

Trying to follow this example to display a custom popup but using MVVM and Shell gives me the error in the title:
https://www.youtube.com/watch?v=yM7opXlu-MU&ab_channel=GeraldVersluis
namespace MyPopupTest
{
public partial class MyViewModel : ObservableObject
{
public MyViewModel()
{
DisplayMyPopup();
}
private void DisplayMyPopup()
{
var popup = new MyPopup();
Shell.Current.ShowPopup(popup);
}
}
}
the popup
using CommunityToolkit.Maui.Views;
namespace MyPopupTest;
public partial class MyPopup : Popup
{
public MyPopup()
{
InitializeComponent();
}
}
This results in an exception: The Parent must be of type Microsoft.Maui.Handlers.PageHandler.
and the stack trace:
at CommunityToolkit.Maui.Core.Views.MauiPopup.SetElement(IPopup element) in /_/src/CommunityToolkit.Maui.Core/Views/Popup/MauiPopup.macios.cs:line 71
at CommunityToolkit.Maui.Core.Handlers.PopupHandler.ConnectHandler(MauiPopup platformView) in /_/src/CommunityToolkit.Maui.Core/Handlers/Popup/PopupHandler.macios.cs:line 91
at Microsoft.Maui.Handlers.ElementHandler`2[[CommunityToolkit.Maui.Core.IPopup, CommunityToolkit.Maui.Core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[CommunityToolkit.Maui.Core.Views.MauiPopup, CommunityToolkit.Maui.Core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].OnConnectHandler(Object platformView)
at Microsoft.Maui.Handlers.ElementHandler.ConnectHandler(Object platformView)
at Microsoft.Maui.Handlers.ElementHandler.SetVirtualView(IElement view)
at Microsoft.Maui.Controls.Element.SetHandler(IElementHandler newHandler)
at Microsoft.Maui.Controls.Element.set_Handler(IElementHandler value)
at Microsoft.Maui.Platform.ElementExtensions.ToHandler(IElement view, IMauiContext context)
at CommunityToolkit.Maui.Views.PopupExtensions.CreatePopup(Page page, Popup popup) in /_/src/CommunityToolkit.Maui/Views/Popup/PopupExtensions.shared.cs:line 59
at CommunityToolkit.Maui.Views.PopupExtensions.ShowPopup[LayingTrackPopup](Page page, LayingTrackPopup popup) in /_/src/CommunityToolkit.Maui/Views/Popup/PopupExtensions.shared.cs:line 27
at MyPopupTest.MyViewModel.DisplayLayingPopup() in /Users/…
Are you sure You are following all steps? Like setting all paths in xaml, setting good references. I have recreated this task but was not able to get this error.
Working example:
Downloading from nuget CommunityToolkit.Maui (version 2.0.0), CommunityToolkit.Mvvm (version 8.0.0)
MauiProgram.cs
public static class MauiProgram
{
public static MauiApp CreateMauiApp()
{
var builder = MauiApp.CreateBuilder();
builder
.UseMauiApp<App>()
.ConfigureFonts(fonts =>
{
fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular");
fonts.AddFont("OpenSans-Semibold.ttf", "OpenSansSemibold");
})
.UseMauiCommunityToolkit();
return builder.Build();
}
}
MainPage.xaml
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:viewmodels="clr-namespace:MauiPopup"
x:DataType="viewmodels:MainPageViewModel"
x:Class="MauiPopup.MainPage">
<ScrollView>
<VerticalStackLayout
Spacing="25"
Padding="30,0"
VerticalOptions="Center">
<Image
Source="dotnet_bot.png"
SemanticProperties.Description="Cute dot net bot waving hi to you!"
HeightRequest="200"
HorizontalOptions="Center" />
<Label
Text="Hello, World!"
SemanticProperties.HeadingLevel="Level1"
FontSize="32"
HorizontalOptions="Center" />
<Label
Text="Welcome to .NET Multi-platform App UI"
SemanticProperties.HeadingLevel="Level2"
SemanticProperties.Description="Welcome to dot net Multi platform App U I"
FontSize="18"
HorizontalOptions="Center" />
<Button
x:Name="CounterBtn"
Text="Click me"
SemanticProperties.Hint="Counts the number of times you click"
Command="{Binding ShowPopupCommand}"
HorizontalOptions="Center" />
</VerticalStackLayout>
</ScrollView>
</ContentPage>
MainPage.xaml.cs
public partial class MainPage : ContentPage
{
public MainPage()
{
InitializeComponent();
BindingContext = new MainPageViewModel();
}
}
MainPageViewModel.cs
internal class MainPageViewModel : ObservableObject
{
public ICommand ShowPopupCommand { get; }
public MainPageViewModel()
{
//ShowPopupCommand = new Command(ShowPopup);
ShowPopup();
}
private void ShowPopup()
{
var popup = new PopupPage();
Shell.Current.ShowPopup(popup);
}
}
PopupPage.xaml
<?xml version="1.0" encoding="utf-8" ?>
<mct:Popup xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:mct="clr-namespace:CommunityToolkit.Maui.Views;assembly=CommunityToolkit.Maui"
x:Class="MauiPopup.PopupPage">
<StackLayout>
<Label Text="Welcome to Maui Popup!"
VerticalOptions="CenterAndExpand"
HorizontalOptions="CenterAndExpand" />
</StackLayout>
</mct:Popup>
PopupPage.xaml
public partial class PopupPage : Popup
{
public PopupPage()
{
InitializeComponent();
}
}

Xamarin Forms - Set BindingContext of a controltemplate

I have a xamarin forms application. It has a tabbedpage within it multiple tabs. The tabbedpage and te tabs, each of them has their own viewmodel as a bindingcontext.
In the app.xaml I defined a controltemplate. I use this control template in each tab, because I want each of those tabs to have a button at the bottom of the page.
At this moment: the button in the controltemplate binds with a property defined in each tab. But I want the button to bind at one place. Isn't it possible to create a viewmodel special for the controltemplate and bind the button defined in the controltemplate with that viewmodel?
Current code:
<ControlTemplate x:Key="ActivityStatusButton">
<StackLayout>
<ContentPresenter>
</ContentPresenter>
<StackLayout VerticalOptions="EndAndExpand" HorizontalOptions="Fill" Padding="15">
<Button Style="{StaticResource RedBackGroundWithWhiteTextButtonStyle}" Command="{TemplateBinding BindingContext.ClickOnStatusButton, Mode=TwoWay}" Text="{TemplateBinding BindingContext.ok, Mode=TwoWay}"></Button>
</StackLayout>
</StackLayout>
</ControlTemplate>
A typical tab:
<ContentPage ...>
<ContentPage.Content>
<Label Text="hello"></Label>
</ContentPage.Content>
<!--The control template is placed here (the button) -->
You could create a Custom Control (a subclass of ContentView) like
<?xml version="1.0" encoding="UTF-8"?>
<ContentView xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:d="http://xamarin.com/schemas/2014/forms/design"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
x:Name="template"
x:Class="App24.MyControlTemplate">
<ContentView.Content>
<StackLayout VerticalOptions="EndAndExpand" HorizontalOptions="Fill" Padding="15">
<Button Clicked="Button_Clicked" Command="{Binding Source={x:Reference template},Path=ButtonCommand}" Text="{Binding Source={x:Reference template},Path=ButtonText}" CommandParameter="{Binding Source={x:Reference template},Path=CommandParameter}" />
</StackLayout>
</ContentView.Content>
</ContentView>
using System;
using System.Windows.Input;
using Xamarin.Forms;
using Xamarin.Forms.Xaml;
namespace App24
{
[XamlCompilation(XamlCompilationOptions.Compile)]
public partial class MyControlTemplate : ContentView
{
public event EventHandler ButtonClick;
public static readonly BindableProperty ButtonTextProperty =
BindableProperty.Create("ButtonText", typeof(string), typeof(MyControlTemplate), default(string));
public string ButtonText
{
get => ((string)GetValue(ButtonTextProperty));
set => SetValue(ButtonTextProperty, value);
}
public static readonly BindableProperty ButtonCommandProperty =
BindableProperty.Create("ButtonCommand", typeof(ICommand), typeof(MyControlTemplate), null, BindingMode.Default, null);
public ICommand ButtonCommand
{
get => (ICommand)GetValue(ButtonCommandProperty);
set
{
SetValue(ButtonCommandProperty, value);
}
}
public static readonly BindableProperty CommandParameterProperty =
BindableProperty.Create("CommandParameter", typeof(object), typeof(MyControlTemplate), null);
public object CommandParameter
{
get => (object)GetValue(CommandParameterProperty);
set => SetValue(CommandParameterProperty, value);
}
public MyControlTemplate()
{
InitializeComponent();
}
private void Button_Clicked(object sender, EventArgs e)
{
ButtonClick?.Invoke(sender, e);
}
}
}
Now you could add it to any page and binding Text , Command or CommandParameter in code behind .
<StackLayout VerticalOptions="CenterAndExpand" HorizontalOptions="CenterAndExpand">
<local:MyControlTemplate ButtonText="{Binding ButtonText}" ButtonCommand="{Binding ClickCommand}" CommandParameter="test" />
</StackLayout>

Search 3 web pages from one user entry (xamarin forms)

I have four tabbed pages (Amazon, Google, and eBay), while the last one is my HomePage. The HomePage has a user entry with a search button below. I want to have the users input be searched on all three web pages(tabbed pages) at the same time. Is there anyway to pass the "entry/input" into the other three pages url? Ex. "(-) + (user entry)" . If someone wants to purchase a new laptop for instance... The first page would take the input and add it to the URL of each page. .... Essentially, webview=("https://www.google.com/" + laptops) and so on for the other two tabbed pages. Hope I explained my question well enough! Thank you all way in advance!!!!
====This is my HomePage.Xaml====
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="App2.HomePage"
Title="Home">
<ContentPage.Content>
<StackLayout>
<Label Text="Home Page"
VerticalOptions="StartAndExpand"
HorizontalOptions="CenterAndExpand"/>
<Entry x:Name="search1" VerticalOptions="Fill"
HorizontalOptions="Fill"/>
<Button Clicked="Button_Clicked_1" Text="Search"
VerticalOptions="Fill" HorizontalOptions="Center"/>
<Entry x:Name="sms" VerticalOptions="FillAndExpand"
HorizontalOptions="Fill"/>
<Button Clicked="Button_Clicked"
Text="Send Text" HorizontalOptions="Center"/>
</StackLayout>
</ContentPage.Content>
</ContentPage>
===This is my HomePage.Xaml.cs===
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Xamarin.Forms;
using Xamarin.Forms.Xaml;
namespace App2
{
[XamlCompilation(XamlCompilationOptions.Compile)]
public partial class HomePage : ContentPage
{
public HomePage()
{
InitializeComponent();
}
public void Button_Clicked(object sender, EventArgs e)
{
string text = sms.Text;
}
public void Button_Clicked_1(object sender, EventArgs e)
{
string text = search1.Text;
}
}
}
===This is my Google.xaml===
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="App2.Views.Google"
xmlns:Content="clr-namespace:App2.Views.HomePage"
Title="Google">
<StackLayout>
<StackLayout Orientation="Horizontal">
<Button Text="<" HeightRequest="40" WidthRequest="45"
Clicked="Back_Clicked"/>
<Button Text=">" HeightRequest="40" WidthRequest="45"
Clicked="Forward_Clicked"/>
<Entry x:Name="URL" WidthRequest="197"/>
<Button Text="Go" HeightRequest="40" WidthRequest="55"
Clicked="Go_Clicked"/>
</StackLayout>
<Label x:Name="LoadingLabel" IsVisible="False"/>
<WebView x:Name="Googlepage" HeightRequest="1000"
WidthRequest="1000"/>
</StackLayout>
</ContentPage>
===This is my Google.xaml.cs===
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using App2.Views;
using Xamarin.Forms;
using Xamarin.Forms.Xaml;
namespace App2.Views
{
[XamlCompilation(XamlCompilationOptions.Compile)]
public partial class Google : ContentPage
{
public Google()
{
InitializeComponent();
URL.Text = ("https://www.google.com/");
Googlepage.Source = "URL.Text";
}
private void Back_Clicked(object sender, EventArgs e)
{
if (Googlepage.CanGoBack)
Googlepage.GoBack();
}
private void Forward_Clicked(object sender, EventArgs e)
{
if (Googlepage.CanGoForward)
Googlepage.GoForward();
}
private void Go_Clicked(object sender, EventArgs e)
{
Googlepage.Source = URL.Text;
}
}
}
There are definitely other ways to do it but one way that comes to mind is a static variable which contains the search text. Then when your user clicks on each tabbed page, when that page loads, just perform the specific search URL including the search text from the static variable.

zkoss is not binding the value

My zkoss code is not binding the value from java method.
<window border="normal" id="home"
apply="com.test.HomeController">
<caption label="#{home.name}"></caption>
<button label="text"></button>
</window>
public class HomeController extends GenericForwardComposer{
public String getName() {
return "MY ZKOSS";
}
}
The window caption is not showing MY ZKOSS . can any one tell me what is the issue?
ZK can use the MVVM pattern.
<window id="win" apply="org.zkoss.bind.BindComposer" viewModel="#id('vm') #init('myController')">
<caption label="#load(vm.myText)"></caption>
</window>
public class myController {
private String name = "MY ZKOSS";
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
ZK Developer Reference - MVVM
value binding through getter for a controller extending from GenericForwardComposer will work with EL expression like label="${$composer.name}"
The kind of data binding you are trying to use will work if controller is extending from component base class for eg HomeController extends from Window instead of GenericForwardComposer. For this to work change apply to use like shown below
<?init class="org.zkoss.zkplus.databind.AnnotateDataBinderInit" ?>
<window border="normal" id="home" use="com.test.HomeController">
<caption label="#{home.name}"></caption>
<button label="text"></button>
</window>
This may help you.
Controller:
package foo;
import org.zkoss.zk.ui.select.SelectorComposer;
import org.zkoss.zk.ui.select.annotation.Wire;
import org.zkoss.zk.ui.select.annotation.Listen;
import org.zkoss.zul.*;
public class MyComposer extends SelectorComposer<Window> {
#Wire
Textbox input;
#Wire
Label output;
#Listen("onClick=#ok")
public void submit() {
output.setValue(input.getValue());
}
#Listen("onClick=#cancel")
public void cancel() {
output.setValue("");
}
}
And in your zul:
<window apply="foo.MyComposer">
<div>
Input: <textbox id="input" />
</div>
<div>
Output: <label id="output" />
</div>
<button id="ok" label="Submit" />
<button id="cancel" label="Clear" />
</window>
the member fields input, output are automatically assigned with components with identifiers of "input" and "output", respectively. The methods submit() and cancel() will be called when user clicks on the corresponding buttons.
http://books.zkoss.org/wiki/ZK_Developer%27s_Reference/MVC/Controller/Composer#Custom_Controller