[prev in list] [next in list] [prev in thread] [next in thread] 

List:       spacewalk-devel
Subject:    [Spacewalk-devel] gen-formbean script
From:       jesusr () redhat ! com (Jesus Rodriguez)
Date:       2008-09-19 2:31:29
Message-ID: 20080919023129.GA3383 () transam ! devel ! redhat ! com
[Download RAW message or body]

I was creating a new form-bean in struts-config.xml and got annoyed
with the process. So I wrote a simple python script called gen-formbean.
It's an interactive script that prompts you for the formbean name,
and any property labels and types.

To avoid typing too much I created a map of the java types to short
strings. For example, if you want java.lang.String simply enter 'string'.
Want java.lang.String[]? enter string_array. Easy huh? What if you want
an org.apache.struts.upload.FormFile? Yep, formfile :)

When you're done it will output the form-bean entry that you can copy and
paste into the struts-config.xml yourself. I hope folks find this useful.
It lives in spacewalk/java/scripts in both master and multiorg branches.

Here's a sample session:

[jesusr at bugatti scripts{multiorg}]$ ./gen-formbean 
form-bean name? sampleForm
property label? name    
property type? string
property label? age
property type? int
property label? fat
property type? bool         <---- notice bool and boolean are the same
property label? tall 
property type? boolean
property label? id
property type? long
property label? filename
property type? formfile
property label? losers
property type? string_array
property label? arches
property type? option
property label?             <---- just hit enter when done

------- PASTE INTO struts-config.xml -----------

<form-bean name="sampleForm"
           type="com.redhat.rhn.frontend.struts.ScrubbingDynaActionForm">
    <form-property name="name" type="java.lang.String" />
    <form-property name="age" type="java.lang.Integer" />
    <form-property name="fat" type="java.lang.Boolean" />
    <form-property name="tall" type="java.lang.Boolean" />
    <form-property name="id" type="java.lang.Long" />
    <form-property name="filename" type="org.apache.struts.upload.FormFile" />
    <form-property name="losers" type="java.lang.String[]" />
    <form-property name="arches" type="org.apache.struts.util.LabelValueBean" />
</form-bean>

-- 
jesus m. rodriguez        | jesusr at redhat.com
sr. software engineer     | irc: zeus
rhn satellite & spacewalk | 919.754.4413 (w)
rhce # 805008586930012    | 919.623.0080 (c)
+-------------------------------------------+
|  "Those who cannot learn from history     |
|   are doomed to repeat it."               |
|                       -- George Santayana |
+-------------------------------------------+



[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic