Wednesday, 10 April 2013

Create Desktop application in Java Using XML

1.There are some Java-based engines to render XUL (using Swing), but I'm not sure what state they are in.

I have had good experience with ANTForm
It generates Java Swing panels from XML. I have used it to build simple GUI apps that execute ANT targets.
Example of the XML declaration:
<antform title="Send Mail" 
    <label>To send a mail, use the following form. Pick a recipient,
 type a subject and a body...the script will do the rest.</label>
    <selectionProperty label="Recipient: " 
    <textProperty label="Subject : " property="subject" />
    <multilineTextProperty label="Message body: "
    <booleanProperty label="Send immediately: " property="send"/>
Example of what it produces:
enter image description here
I used Apache Pivot and really liked it.

Create Desktop application in java using HTML

Using JavaFX

Q. Difference between Declarative and Programmatic/Procedural approach?

Ans :
A Procedural language provides "assignments" to keep and/or alter the states while executing through steps. It provides the means to express WHAT a program can do in STEPS (the HOWs) 
A pure declarative programming language has no concept of "assignments" to allow you alter states. It allow the programmers to express what the software can do only. (not the how-part)

I suppose there is always a programmatic approach available since the UI is not made of magic. I guess declarative UIs are just build on the top of programmatic UIs

Describe a result and get it via a black box. Examples:
·         yacc
·         Treetop
·         SQL
·         Regular Expressions
·         lex
·         XSLT
·         Markup (XML,HTML etc), troff, CSS, VHDL
Describe the algorithm and process steps, at various degrees of abstraction.
·         C, most legacy languages
·         PHP, mostly
·         in some sense all major languages
Object Oriented
·         Tends to be in the procedural category, typically refers to languages that exhibit a hierarchy of types that inherit both methods and state from base types to derived types, but also kind of includes prototype-based languages like JavaScript. Somewhat a separate dimension from the other categories here.
You left this one out. The opposite of imperative programming, it emphasizes the application of functions without side effects and without mutable state. The declarative systems above exhibit certain aspects of functional programming.
·         Scheme
·         Erlang
·         OCaml
·         Haskell
·         Lisp, depending. (Lisp perhaps deserves its own unique category)
·         Clojure, somewhat
·         Ruby, somewhat less
·         F#
Building User Interfaces with JSF: Declarative vs. Programmatic Approach
When we are using JSF tags to build the user interface, we are using the declarative approach. With declarative approach we can visualize the hierarchy of the user interface.
Let’s see how it’s possible to produce the same user interface using both approaches. We will build the following simple panel:
Here is an example of declarative approach:
  <h:outputText value="I love New York"/>  <h:outputText value="I love the Big Apple and using RichFaces"/> 
Using tags mimics better how the actual user interface will look. In other words, it’s easier to build the user interface using tags.
Here is an example of programmatic approach that produces exactly the same page:
Application application = FacesContext.getCurrentInstance().getApplication(); // create rich:panel HtmlPanel panel = (HtmlPanel)application.createComponent(HtmlPanel.COMPONENT_FAMILY); // set width panel.setStyle("width:400px"); // create h:outpuText HtmlOutputText outputTextHeader = (HtmlOutputText)application.createComponent(HtmlOutputText.COMPONENT_TYPE); // set h:outputText value outputTextHeader.setValue("I love New York"); // add header facet to rich:panel panel.getFacets().put("header", outputTextHeader); // create h:outputText HtmlOutputText outputText = (HtmlOutputText)application.createComponent(HtmlOutputText.COMPONENT_TYPE); // set h:outputText value outputText.setValue("I love the Big Apple and using RichFaces"); // add h:outputText as a child to rich:panel panel.getChildren().add(outputText);
As you can probably see, when using programmatic approach, it’s more difficult to visualize and understand the hierarchy of the user interface. It basically looks flat.
While most of JSF pages will be built using the declarative style, programmatic approach will almost always be required in a large application. In situations where pages are highly dynamic, the programmatic approach provides power and flexibility. The programmatic approach is also needed when components need to be manipulated inside a Java class (for example managed beans). A common example of this would be using the ‘binding’ attribute and setting some property of the component, for example:
The programmatic approach is not “bad� as long as you know how and when to use it.
This is just to give you an idea what is the difference between declarative and programmatic approaches to developing user interfaces. Of course JSF provides a declarative approach to build the user interface using JSF and RichFaces tags