Package net.xoetrope.builder

Examples of net.xoetrope.builder.XuiBuilder


  }
 
  private void setupComponents( PageSupport page, Object source, Class pageClass )
  { 
    XProject currentProject = page.getProject();
    XuiBuilder builder = (XuiBuilder)currentProject.getObject( "Builder" );
   
    Field[] fields = pageClass.getDeclaredFields();
    for ( Field field : fields ) {    
      boolean isAccessible = field.isAccessible();
      if ( !isAccessible ) {
        try {
          field.setAccessible( true );
        }
        catch ( SecurityException ex ) {
          // There may be a security policy in place preventing this
          ex.printStackTrace();
        }
      }
     
      String fieldName = field.getName();
      Object targetComp = null;
     
      // Setup the annotated component references
      Annotation annotation = field.getAnnotation( Find.class );
      if ( annotation != null ) {
        try {
          targetComp = page.findComponent( fieldName );
          if ( BuildProperties.DEBUG ) {
            if ( targetComp == null ) {
              DebugLogger.logError( "The annotated component \"" + fieldName + "\" was not found in the page." );
              continue;
            }
          }
          field.set( source, targetComp );     
        }
        catch ( IllegalArgumentException iae )
        {
          if ( BuildProperties.DEBUG )
              DebugLogger.logError( "The annotated component \"" + fieldName + "\" does not match the type of component declared in the page." );         
        }
        catch ( Exception e )
        {
          e.printStackTrace();
        }
      }
     
      // Setup the annotated data bindings
      annotation = field.getAnnotation( Bind.class );
      if ( annotation != null ) {
        try {
//          String srcStr = ((Bind)annotation).value();
//          XModel srcModel = (XModel)page.getProject().getModel().get( page.evaluatePath( srcStr ));

          Hashtable instanceConfig = new Hashtable();
          String extraStr = ((Bind)annotation).extra();
          StringTokenizer tokenizer = new StringTokenizer( extraStr, "," );
          while( tokenizer.hasMoreTokens()) {
            String token = tokenizer.nextToken();
            int pos = token.indexOf( '=' );
            instanceConfig.put( token.substring( 0, pos ), token.substring( pos + 1 ));
          }
         
          if ( targetComp == null )
            targetComp = page.findComponent( fieldName );
         
          XDataBinding binding = builder.getFactoryBinding( page, targetComp, instanceConfig );
          page.addBinding( binding );
        }
        catch ( Exception e )
        {
          e.printStackTrace();
View Full Code Here

TOP

Related Classes of net.xoetrope.builder.XuiBuilder

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.