facebook

JSF data input form wizard

  1. MyEclipse IDE
  2.  > 
  3. Feature Requests
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #233572 Reply

    dkittle
    Member

    One of the more compelling ideas behind GUI-centric frameworks like JSF is their ability to help make CRUD-based websites (which primary deal with creating, updating and deleting database data) very quick to develop. A visual editor for JSF would be nice, but since that is only going to be available to Windows users in the near term, I’m wondering if you might consider building a template driven wizard for form based JSF pages…

    The wizard would be driven from File->New->MyEclipse-JSF->Form Page. The wizard would prompt for the file path, the JSP filename, the name of the managed bean that the form on the page will be generated from and the number of columns to use in the panelGrid that will wrap the input fields of the form.

    The wizard would rely on page template and a property mapping system. The page template would be very simple, similar to your existing JSP template. The exception being a token or placeholder in the template where the generated form goes.

    The property mapping system would be the interesting part of the wizard… The motivation for building a system to map object properties to form input text is provide a simple system of generating developer customized text based on either the name of property of it’s type. The mapping system would be customized in MyEclipse preferences. Mappings key off of a properties name or type, giving preference to name. This means we could define a mapping for a property with the name “email” or a mapping for the type java.util.Date. The developer could then specify a ‘template’ for this mapping. The template would be text that would substitute certain tokens as each property in the managed bean is processed. Tokens might include:
    [[beanName]] = the name of the managed bean (as defined in faces-config and supplied as part of the wizard above)
    [[beanClassSimpleName]] = the name of the managed bean’s class without the package name (java.util.Date has the simple name Date)
    [[propertyName]] = the name of the property being processed
    I’ve used [[ and ]] to delineate my tokens for this example…

    Some possible mappings that I would set up include:

    
    key: java.util.Date (a "type" mapping)
    text: <h:inputText value="#{[[beanName]].[[propertyName]]}"><f:convertDateTime pattern="yyyy/MM/dd"/></h:inputText>
    
    key: email (a "name" mapping)
    text: <h:inputText value="#{[[beanName]].email}"><f:converter converterId="com.company.converters.Email"/></h:inputText>
    
    key: age (a "name" mapping)
    text: <h:inputText value="#{[[beanName]].age}"><f:validLongRange minimum="13" maximum="200"/></h:inputText>
    

    The wizard would iterate through all properties of the managed bean, looking for a mapping that matches either the name of the property or the type of the property (maybe a mapping with a name of * would be a catch-all that would be used if the property’s real name or type is not mapped). If a mapping is found, the tokens in the mapping text are replaced with read values that text is added to the JSP’s form.

    So if I had a com.company.domain.User object mapped in the faces-config using:

    
    <managed-bean>
      <managed-bean-name>user</managed-bean-name>
      <managed-bean-class>com.company.domain.User</managed-bean-class>
    </managed-bean>
    

    and I had the mappings above with my default mapping of:

    
    key: * (the "default" mapping)
    text: <h:inputText value="#{[[beanName]].[[propertyName]]}"/>
    

    and the user class looked like:

    
    package com.company.domain.User;
    public class User {
    private String name;
    private String email;
    private Date dateOfBirth;
    public String getName() { return name; }
    public void setName(String v) { name = v; }
    public String getEmail() { return email; }
    pubilc void setEmail(String v) { email = v; }
    public Date getDateOfBirth() { return dateOfBirth; }
    public void setDateOfBirth(Date v) { dateOfBirth = v; }
    }
    

    The wizard might produce something like:

    
    <h:inputText value="#{user.name}"/>
    <h:inputText value="#{user.email}"><f:converter converterId="com.company.converters.Email"/></h:inputText>
    <h:inputText value="#{user.dateOfBirth}"><f:convertDateTime pattern="yyyy/MM/dd"/></h:inputText>
    

    Disclaimer: I did not include form input labels nor error message output in my examples to make this more readible, but imagine the possibilities if this was included… Don’t format your javabeans as I’ve done in my example 🙂

    #233635 Reply

    Riyad Kalla
    Member

    dkittle,
    Excellent and well thought out request, I will file this for consideration. Depending on our internal roadmap and resources available we can determine if this is dooable or something we want to tackle at this point.

Viewing 2 posts - 1 through 2 (of 2 total)
Reply To: JSF data input form wizard

You must be logged in to post in the forum log in