extscript-examples/blog-example/src/main/webapp/WEB-INF/java/blog/Blog.java [32:144]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@DependencyTestAnnotation
public class Blog {

    
    String title = "<h3>Hello to the MyFaces Dynamic Blogging Example</h3>";
    String title1 = "You can alter the code for this small blogging application on the fly, " +
            "you even can add new classes on the fly and Java will pick it up";

    String firstName = "";
    String lastName = "";
    String topic = "";

    String content = "";

    private Logger getLog() {
        return Logger.getLogger(this.getClass().getName());
    }

    public String addEntry() {
        getLog().info("adding entry");
        
        /*important we have an indirection over an interface here*/
        BlogServiceInterface service = (BlogServiceInterface) resolveVariable("javaBlogService");

        if (service == null) {
            getLog().severe("service not found");
        } else {
            getLog().fine("service found");
        }

        BlogEntry entry = new BlogEntry();
        //we now map it in the verbose way, the lean way would be to do direct introspection attribute mapping

        entry.setFirstName(firstName);
        entry.setLastName(lastName);
        entry.setTopic(topic);
        
        entry.setContent(content);

        if (service != null) {
            /*convenience method to call a method on an object dynamically
            * executeMethod and cast are static imports which encapsulates the
            * ugly stuff the java introspection provides and reduce
            * the loc down to sane levels
            *
            * note the behavior in case of calling errors
            * is changed from the default managed behavior
            * to an unmanaged behavior. This is mostly
            * the same behavior you get from scripting engines!
            * 
            */

            //include for presentation 3
            //entry.setTopic(debuggingTest());
              
            service.addEntry(entry);
        }

        //we stay on the same page
        return null;
    }

    //include for presentation 3
    /*public String debuggingTest() {
        return "Debugging Topic set via dynamic code";
    }*/

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getTitle1() {
        return title1;
    }

    public void setTitle1(String title1) {
        this.title1 = title1;
    }

    public String getFirstName() {
        return firstName;
    }

    public void setFirstName(String firstName) {
        this.firstName = firstName;
    }

    public String getLastName() {
        return lastName;
    }

    public void setLastName(String lastName) {
        this.lastName = lastName;
    }

    public String getTopic() {
        return topic;
    }

    public void setTopic(String topic) {
        this.topic = topic;
    }

    public String getContent() {
        return content;
    }

    public void setContent(String content) {
        this.content = content;
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



extscript-examples/myfaces20-example/src/main/webapp/WEB-INF/java/org/apache/myfaces/javaloader/blog/Blog.java [32:144]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@DependencyTestAnnotation
public class Blog {

    
    String title = "<h3>Hello to the MyFaces Dynamic Blogging Example</h3>";
    String title1 = "You can alter the code for this small blogging application on the fly, " +
            "you even can add new classes on the fly and Java will pick it up";

    String firstName = "";
    String lastName = "";
    String topic = "";

    String content = "";

    private Logger getLog() {
        return Logger.getLogger(this.getClass().getName());
    }

    public String addEntry() {
        getLog().info("adding entry");
        
        /*important we have an indirection over an interface here*/
        BlogServiceInterface service = (BlogServiceInterface) resolveVariable("javaBlogService");

        if (service == null) {
            getLog().severe("service not found");
        } else {
            getLog().fine("service found");
        }

        BlogEntry entry = new BlogEntry();
        //we now map it in the verbose way, the lean way would be to do direct introspection attribute mapping

        entry.setFirstName(firstName);
        entry.setLastName(lastName);
        entry.setTopic(topic);
        
        entry.setContent(content);

        if (service != null) {
            /*convenience method to call a method on an object dynamically
            * executeMethod and cast are static imports which encapsulates the
            * ugly stuff the java introspection provides and reduce
            * the loc down to sane levels
            *
            * note the behavior in case of calling errors
            * is changed from the default managed behavior
            * to an unmanaged behavior. This is mostly
            * the same behavior you get from scripting engines!
            * 
            */

            //include for presentation 3
            //entry.setTopic(debuggingTest());
              
            service.addEntry(entry);
        }

        //we stay on the same page
        return null;
    }

    //include for presentation 3
    /*public String debuggingTest() {
        return "Debugging Topic set via dynamic code";
    }*/

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getTitle1() {
        return title1;
    }

    public void setTitle1(String title1) {
        this.title1 = title1;
    }

    public String getFirstName() {
        return firstName;
    }

    public void setFirstName(String firstName) {
        this.firstName = firstName;
    }

    public String getLastName() {
        return lastName;
    }

    public void setLastName(String lastName) {
        this.lastName = lastName;
    }

    public String getTopic() {
        return topic;
    }

    public void setTopic(String topic) {
        this.topic = topic;
    }

    public String getContent() {
        return content;
    }

    public void setContent(String content) {
        this.content = content;
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



