Things that need to be considered

8 views
Skip to first unread message

Bill

unread,
Nov 11, 2009, 1:44:31 PM11/11/09
to Induction Framework
Hello Adi and All,

I would like to list several points that are subjects for Induction's
enhancements :
- Controller : Instead of a marker interface, it would be nice if
Controller is implemented as an abstract class and implement several
useful getters (e.g. Response, Request, Model Dictionary, etc ).
- Model-View's Interaction : It would be good there will be a section
within tutorial page explains about interaction between a Model and a
View ( e.g. How a model's property is rendered within somewhere points
within the View , through inline scripting maybe).
- Model : Adi, i believe you & me would agree that Induction should
minimize numbers of XML's configuration. I think this concept should
be applied on Induction's Model as well. Implementing Induction's
Model will require us to declare another XML Configuration ( <model-
defs> , <model-def> ) and they will require us to write its factory
class. This is ok, i respect it. However, why don't create a getter
within Controller ( i wish this one is not just a marker interface,
but an abstract class ) , say 'Dictionary<string,object> getModel() ',
to get a reference to Models dictionary. This dictionary will be
visible between Controller and View. Whenever we need to pass our
instance of objects between Controller to View , we should be able to
do it like this one :
// Controller side
public void handler(Request request){
// ..... do something
String requestedVideoTitle = request.getParameter("videoTitle");
getModel().put("Video", myVideoService.getVideo
(requestedVideoTitle));
}
At this way, no XML configuration & factory class for mapping the
model will be needed to be existed. It should be simpler as the ones
that i looked within PHP's CodeIgniter or ASP NET MVC.

I think that's all of my current suggestions at the moment. Looking
forward for your feedback.

Cheers.

Adinath

unread,
Nov 14, 2009, 5:22:01 PM11/14/09
to induction...@googlegroups.com
Bill,

Thanks for your suggestions, my responses follow:

On Wed, Nov 11, 2009 at 11:44 AM, Bill <saint...@gmail.com> wrote:
I would like to list several points that are subjects for Induction's
enhancements :
- Controller : Instead of a marker interface, it would be nice if
Controller is implemented as an abstract class and implement several
useful getters (e.g. Response, Request, Model Dictionary, etc ).

The approach used in Induction is to provide these values via dependency injection. You can access the Request, Response, and model object and a host of other values simply by declaring a parameter of the respective type in your controller method. An example is shown below:

import com.acciente.induction.controller.Controller;

public class OrderController implements Controller
{
   // note how the OrderApp model is injected below
   public void open( Form form, OrderApp orderApp )
   {
      orderApp.open( form.getString( "orderID" ) );

      // more controller logic for open goes here...

     // finally return a redirect that takes the user to a page that displays the order details
     return new Redirect( OrderDetailsPage.class );
   }

   // note how we are injecting the Response object
   public void printSummary( HttpServletResponse response, OrderApp orderApp )
   {
       Writer writer = response.getWriter();

       writer.println( orderApp.getOrderSummary() );
   }
}

Providing values via getters is not flexible, since when it comes to models Induction could not have getters with specific return types since the models are unknown ahead of time. Having getters that return Object or the like would make for poor typing and not allow dependency analysis using an IDE.

You can find the full set of values available to a controller method here:

http://www.inductionframework.org/param-injection-1-reference.html#ControllerMETHODScommonlyusedparametertypes
 
- Model-View's Interaction : It would be good there will be a section
within tutorial page explains about interaction between a Model and a
View ( e.g. How a model's property is rendered within somewhere points
within the View , through inline scripting maybe).

Thanks! This is not covered well in the tutorial. Basically you can inject any model into a view constructor. The full set of values available to a view constructor is documented here:

http://www.inductionframework.org/param-injection-1-reference.html#ViewCONSTRUCTORcommonlyusedparametertypes

- Model : Adi, i believe you & me would agree that Induction should
minimize numbers of XML's configuration. I think this concept should
be applied on Induction's Model as well. Implementing Induction's
Model  will require us to declare another XML Configuration ( <model-
defs> , <model-def> ) and they will require us to write its factory
class. This is ok, i respect it.

Bill, I think Induction takes a pretty minimal approach to XML relative to other frameworks. That said the factory classes are optional, if there is no factory class Induction will directly call the constructor of your model to create it (it is expected to have a single public constructor).

Note that with about 4-5 lines of XML is all you need per model, and for that Induction manages the scope of the model (Application, Session and Request) and also does dependency injecting for parameter values into the model constructor (or the factory's createModel( ... ) method) when it instantiates a model.

You can read more about how Induction manages models here: http://www.inductionframework.org/using-models-tutorial.html
 
However, why don't create a getter
within Controller ( i wish this one is not just a marker interface,
but an abstract class ) , say 'Dictionary<string,object> getModel() ',
to get a reference to Models dictionary. This dictionary will be
visible between Controller and View. Whenever we need to pass our
instance of objects between Controller to View , we should be able to
do it like this one :
// Controller side
public void handler(Request request){
  // ..... do something
  String requestedVideoTitle = request.getParameter("videoTitle");
  getModel().put("Video", myVideoService.getVideo
(requestedVideoTitle));
}
At this way, no XML configuration & factory class for mapping the
model will be needed to be existed. It should be simpler as the ones
that i looked within PHP's CodeIgniter or ASP NET MVC.

Here is how your above example can look in Induction:

public class VideoRentalController implements Controller
{
    public void checkoutVideo( VideoService videoService, Form form )
    {
        VideoTitle videoTitle = videoService.getVideoTitle( form.getString( "videoTitle") );

        videoService.checkOutVideo( videoTitle );

        // .... do more stuff with the video title

       return new Redirect( VideoCheckoutConfirmationPage.class );
    }

    public void returnVideo( VideoService videoService, Form form )
    {
        VideoTitle videoTitle = videoService.getVideo( form.getString( "videoTitle") );

        // .... do stuff with the video title

        videoService.returnVideo( videoTitle );

        // .... do more stuff with the video title

       return new Redirect( VideoReturnConfirmationPage.class );
    }
}

Hope this addresses the points you raised.

Thanks,
Adi


--
Acciente, LLC
Systems Architecture and Software Design

www.acciente.com
www.inductionframework.org
Message has been deleted

Bill

unread,
Nov 17, 2009, 7:19:28 AM11/17/09
to Induction Framework
Hello Adi,

Thank you for your reply. I think Induction got my attention now.
Please
include your prior replies into Induction's FAQ or other sections. I
believe
they will be really helpful for users.
Oh, one more thing. It would be nice if there is a sample that show
AJAX
demonstration, maybe just using JQuery. It would be nice as well for
us :-D.

Cheers,

Bill

- Hide quoted text -
- Show quoted text -
On Sun, Nov 15, 2009 at 6:22 AM, Adinath <adin...@acciente.com> wrote:
> Bill,

> Thanks for your suggestions, my responses follow:

> http://www.inductionframework.org/param-injection-1-reference.html#Co...

>> - Model-View's Interaction : It would be good there will be a section
>> within tutorial page explains about interaction between a Model and a
>> View ( e.g. How a model's property is rendered within somewhere points
>> within the View , through inline scripting maybe).

> Thanks! This is not covered well in the tutorial. Basically you can inject
> any model into a view constructor. The full set of values available to a
> view constructor is documented here:

> http://www.inductionframework.org/param-injection-1-reference.html#Vi...
> --
> You received this message because you are subscribed to the Google Groups
> "Induction Framework" group.
> To post to this group, send email to induction...@googlegroups.com.
> To unsubscribe from this group, send email to
> induction-frame...@googlegroups.com<induction-framework%2Bunsu...@googlegroups.com>
> .
> For more options, visit this group at
> http://groups.google.com/group/induction-framework?hl=.


Reply Reply to author Forward



You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before
posting.
You do not have the permission required to post.


On Nov 15, 6:22 am, Adinath <adin...@acciente.com> wrote:
> Bill,
>
> Thanks for your suggestions, my responses follow:
>
> http://www.inductionframework.org/param-injection-1-reference.html#Co...
>
> > - Model-View's Interaction : It would be good there will be a section
> > within tutorial page explains about interaction between a Model and a
> > View ( e.g. How a model's property is rendered within somewhere points
> > within the View , through inline scripting maybe).
>
> Thanks! This is not covered well in the tutorial. Basically you can inject
> any model into a view constructor. The full set of values available to a
> view constructor is documented here:
>
> http://www.inductionframework.org/param-injection-1-reference.html#Vi...

Adinath

unread,
Nov 20, 2009, 4:05:27 PM11/20/09
to induction...@googlegroups.com
Bill,

Thanks, glad to hear. Will do.

Adi

To unsubscribe from this group, send email to induction-frame...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/induction-framework?hl=.


Reply all
Reply to author
Forward
0 new messages