[ 
https://issues.apache.org/jira/browse/TOMAHAWK-1250?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Ji Kim updated TOMAHAWK-1250:
-----------------------------

    Status: Patch Available  (was: Open)

> Adobe Flex components as MyFaces JSF components
> -----------------------------------------------
>
>                 Key: TOMAHAWK-1250
>                 URL: https://issues.apache.org/jira/browse/TOMAHAWK-1250
>             Project: MyFaces Tomahawk
>          Issue Type: New Feature
>         Environment: Have tested using os [windows xp], browsers [firefox 
> 2.0, opera 9.25, ie 6.0], and app server [tomcat 5.5.23].
>            Reporter: Ji Kim
>         Attachments: mxmlComp.patch, mxmlComp.zip, 
> mxmlExamplescreenshot-1.jpg, patchZip.txt
>
>
> I wished to contribute set of components to give users capability in creating 
> Adobe Flex components as MyFaces JSF components. So users would create the 
> components as normal JSF components and the contribution will create the 
> necessary SWF files and etcetera and link the values of the components back 
> to the managed beans using JSON+Javascript and etcetera.
> The components require Adobe Flex SDK to be extracted to C:\Program 
> Files\flexSDK or /usr/local/bin/flexSDK.
> Optionally users can modify the mxmlConstants.xml or can pass the directory 
> as a JVM parameter mxmlc_bin
> Requires ANT during compile time, so have modified the sandbox's POM with the 
> dependency.
> Have tested using FireFox 2.0, Opera 9.25, and IE 6.0 browsers with TomCat 
> 5.5. Also have used Sun's JDK for Adobe Flex SDK [JAVA_HOME].
> The basic design is as follows [will implement it better later] :
> (1)   All Flex components must be nested within <s:mxmlApplication /> tag as 
> it is the top component and this tag must be outside the <h:form /> component 
> [due to IE's  
>           use of objects].
> (2)   There exists replaceMapping XMLs which will tell how to pick the fields 
> from the components [i.e. by attributes of the UIComponent or by method call 
> for that object].
> (3)   There exists templates [users can modify it if they wish to have some 
> default capability to all similar component] which will be used per component 
> to create preMxml 
>           files. In a nutshell, it is nothing but a simple file that contains 
> tokens which will be replaced by component values using the replaceMapping 
> XML and ANT's Replace 
>           Task.
> (4)   Necessary source files will be created to their respective directory 
> [i.e. ActionScript file[s] that is/are needed by the system and XML file[s] 
> that is/are needed by the 
>           ActionScript files[s] and should be defined within 
> mxmlConstants.xml]
> (5)   After all the components' preMxml within <s:mxmlApplication /> have 
> been created, MXML file and SWF file will be created using ANT by the 
> MXMLApplication class. 
>           <s:mxmlScript /> will give capability in writing ActionScript       
> contents as the body content of the Tag by extending UIComponentBodyTagBase. 
> Similar flexibility is given to 
>           other       Tags by extending MXMLUIComponentBodyTagBase; however 
> it should be used sparingly and should be used mainly for components that 
> extend 
>           MXMLUISimpleBase component. One additional thing to note is that 
> mxmlPackageName attribute for <s:mxmlApplication /> tag will be used to name 
> the mxml file and 
>           the swf file.
> (6)   Also <s:mxmlApplication /> will create JSON objects which will be 
> rendered onto the page for initial values of the Flex components.  The reason 
> for this is because 
>           <s:mxmlApplication /> has various modes :
>               debugMode       =>  meaning preMxml, Mxml, and SWF files would 
> be created in each run as well as JSON objects
>               simplySWF        =>  meaning Mxml which has been modified by 
> the user exists, so create only SWF files and JSON objects [users can use 
> this to modify the mxml 
>                                                    file and create a swf file]
>               productionEnv   => meaning SWF file already exists, so nothing 
> to do here but create JSON objects [this is the default value to ensure that 
> users do not run the 
>                                                   components in either of the 
> two other modes in an environment that is higher than dev]. One thing to note 
> is that all directories of 
>                                                   WebContent/swf/* should be 
> copied to their corresponding directory within the Workspace during the move 
> to higher env [since the 
>                                                   system uses 
> servContext.getRealPath(new String()) as the root directory of preMxml, Mxml, 
> and swf directory and TomCat for example flushes it  
>                                                   out to their cache 
> directory under metadata].
>        For large components such as DataGrid, am planning to write it as a 
> service in retrieving and setting the values
> (7)   Uses dojo during the onLoad time to connect all the Form's onsubmit 
> event with a pageUnload function.
>       Also each Flex/Flash app will communicate back to the page when it has 
> finished setting up on its side [such as setting callBack methods and 
> etcetera], JSON will be 
>         passed to the apps to set the initial values with the check interval 
> set to 500 milliseconds. So the values will be decoded [for example htmlText 
> allows XML tags and 
>       etcetera, so on the Java side there will be encoding and decoding on 
> the Flex/Flash side] and set to the component's values.
> (8)   During the form's onsubmit action, pageUnload will return false and 
> make a call to Flex/Flash app to return the component's values to the page. 
> When returned, nodes 
>         will be appended to the form that was in the process of       
> submission and will submit the page 
>       On the Flex/Flash side, there will be an ActionScript which will use 
> E4X [love it] to look up within an XML file the property/attributes that the 
> component must return as 
>         JSON objects to the page, so that the page can create the elements 
> with their attributes as child nodes of the form element.
> Will write this better later and will plan on making the code much cleaner 
> and better during free time, but wanted to see if this is something that 
> could be considered as a contribution within the group. Thanks!!!
> Oh yes, one note regarding preMxml files. In order to keep everything simple 
> and debugging easy, a simple method was chosen to create the preMxml files 
> for each component. Namely the file with mxmlPackageName_[Major Num][Minor 
> Num].pre_mxml will be created per component within directory named 
> WebContent/preMxml/[mxmlPackageName]/. So for instance, MxmlApplication will 
> have Major Num and Minor Num set to 0 and the first child of MxmlApplication 
> will have [1,0] set with it's sibling set to [1,1] and etcetera. Due to how 
> it's written, there maybe an issue such that when depth equals a certain 
> value and the components within that depth has 3 digits.
> For example,
>       001121  this can mean 
>               (1) major level 1 with minor level 121 {meaning there exists at 
> least 120 components within the swf}
>               (2) major level 2 with minor level 1 {meaning this is a child 
> of [1,1] and the second sibling with depth two}
>       Since issues with this kind of scenario will occur when (1) doesn't 
> exist [meaning sibling 120 exists and 121 is placeholder] and (2) exists 
> [meaning [2,1] exists], this will 
>         be very rare. Also if someone has over 100+ components within a 
> single swf file, I think it should be reconsidered and rewritten.
> I will possibly considering writing more regarding it later during my free 
> time. Thanks!!!

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to