jaroslav@106: /** jaroslav@106: * Back 2 Browser Bytecode Translator jaroslav@106: * Copyright (C) 2012 Jaroslav Tulach jaroslav@106: * jaroslav@106: * This program is free software: you can redistribute it and/or modify jaroslav@106: * it under the terms of the GNU General Public License as published by jaroslav@106: * the Free Software Foundation, version 2 of the License. jaroslav@106: * jaroslav@106: * This program is distributed in the hope that it will be useful, jaroslav@106: * but WITHOUT ANY WARRANTY; without even the implied warranty of jaroslav@106: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the jaroslav@106: * GNU General Public License for more details. jaroslav@106: * jaroslav@106: * You should have received a copy of the GNU General Public License jaroslav@106: * along with this program. Look for COPYING file in the top folder. jaroslav@106: * If not, see http://opensource.org/licenses/GPL-2.0. jaroslav@106: */ jaroslav@100: package org.apidesign.bck2brwsr.htmlpage; jaroslav@100: jaroslav@100: import org.apidesign.bck2brwsr.htmlpage.api.OnClick; jaroslav@100: import org.apidesign.bck2brwsr.htmlpage.api.Page; jaroslav@100: jaroslav@100: /** Trivial demo for the bck2brwsr project. First of all start jaroslav@100: * with your XHTML page. Include there jaroslav@100: * a script that will boot Java in your browser. jaroslav@100: *

jaroslav@100: * Then use @Page annotation to jaroslav@100: * generate a Java representation of elements with IDs in that page. jaroslav@100: * Depending on the type of the elements, they will have different jaroslav@100: * methods (e.g. PG_TITLE has setText, etc.). jaroslav@100: * Use @OnClick annotation to associate behavior jaroslav@100: * with existing elements. Use the generated elements jaroslav@100: * (PG_TITLE, PG_TEXT) to modify the page. jaroslav@100: *

jaroslav@100: * Everything is type-safe. As soon as somebody modifies the page and jaroslav@100: * removes the IDs or re-assigns them to wrong elements. Java compiler jaroslav@100: * will emit an error. jaroslav@100: *

jaroslav@100: * Welcome to the type-safe HTML5 world! jaroslav@100: * jaroslav@100: * @author Jaroslav Tulach jaroslav@100: */ jaroslav@100: @Page(xhtml="TestPage.html", name="TestPage") jaroslav@100: public class PageController { jaroslav@100: @OnClick(id="pg.button") jaroslav@100: static void updateTitle() { jaroslav@104: TestPage.PG_TITLE.setText("You want this window to be named " + TestPage.PG_TEXT.getValue()); jaroslav@100: } jaroslav@100: }