"Profile-based" MVC applications

Discussions

J2EE patterns: "Profile-based" MVC applications

  1. "Profile-based" MVC applications (11 messages)

    Hi folks,

    I've already posted this in the Web Tier Discussion, but looks like it's more oriented on technical problems with struts, so... All pologies in advance for cross-posting, but I think it's not a big problem, and it may help in pushing the concept forward.

    I'll try to be as concise and clear as possible, to present things quickly here and let you browse existing resources to keep my post a bit short.

    All my story is, in a few words, about presenting "customized pages" to end-users (HTML pages at the moment, but the concept is also true for desktop apps) depending on their "role", "group", or whatever else...

    As a matter of fact, many of you may remember an application that included the infamous "login page", and where specific pages had to be presented for users of different "nature"...

    Well, I looked for something cool on the web to do so a few years ago, but nothing existed yet (or I did not find it).
    Some ideas from great people (through the CorbaWeb project) came on top of this, and I started thinking about a framework to do this...

    'JWebViews' was born.

    It's a frawemork built on top of the servlet API that allows to display customized pages for some "profiles" and some "target objects".
    In a few words, this allows to assign "actions" (some controllers that are invoked by the framework on the behalf of user interactions) to some "objects" and some "profiles". Of course, the "profiles" represent you application's users, roles, etc.

    This allows to define profiled views of your model's objects...

    Describing all this short is quite hard actually, so don't hesitate to read the framework documentation there :
    http://www.rvkb.com/jwebviews/doc/Framework/index.html

    I've been using this "home-made" framework in several applications (even other developers did ! :-) ), and it revealed very efficient. I think it's much simpler than struts & such things (actually because it has no such taglib and tools... but it keeps the MVC principle which is always good IMHO) but lets you do very powerful things when it comes to designing multi-profile web applications.

    If you'd like to react, don't hesistate ! I'm looking for people to push this concept forward.
    I think this story of executing UI code for objects and profiles is quite interesting...

    Also, some points in the framework are still to be investigated (JAAS-based auth., action linking, IDE tools, ... so many things actually !) to make it even more cool !

    Well, enjoy it ! Feedback most appreciated !

    Cheers

    Remi

    Threaded Messages (11)

  2. "Profile-based" MVC applications[ Go to top ]

    Hi Remi,

    We had the similar problem where we needed to skin the web app to the flavour of the user. Since the absence of a framework, we developed a small in-house solution. Define all the images / CSS that make the web page in JSP tags and load the specific image based on the role from a database table. Though it did not solve the problem of changing the layout of the html page, but it did change the page a fair bit to make it look different.

    Thanks
  3. "Profile-based" MVC applications[ Go to top ]

    Hi Guneet,

    Well, JWebViews allows more than this actually, but it would have solved your problem too :-)
    Also, you could even have used your own existing "roles" database table...
    The main thing, for "profile skinning", would have been to change CSS in the generation of each page head in a dedicated action (JWebViews' profiled controllers).
    "If A is browsing than use CSS 1, if B then use CSS 2..."

    So, yes it actually solves your problem. I'd even say it could open new perspectives in your app :-)

    What it allows is for example to have pages with HTML <form>s and <input>s (allow update) for user "A" who inherits from profile "admin", and regular labels for user "B" who's under "standard" profile...
    You usually have this in your apps : model objects (finally, a GUI is often used to browse model objects in some way) are read-only (plain text) for standard users, but some others that are granted can edit objects and change properties...

    Conceptually, JWebViews allows to define "profiled" controllers... This means you can behave as you want upon requesting profile.

    Of course, it's fully Servlet compliant, and lets you define composite pages almost as you already do by assembling "panels"... in JwebViews these are just the result of profiled actions !

    Thanks for your feedback !

    Cheers

    Remi
  4. Why don't you....[ Go to top ]

    Its a great concept, Why don't you try to push it into some great open source Web framework like WebWork?
    I don´t understand the need to redo everything end to compete with everybody. But I do understand the need to do things your way in the beggining so you do not have to deal with how other people think.
    Please do not compete, try to find some already stablished framework to adopt and maintain it.
  5. Why don't you....[ Go to top ]

    Hi Luis,
    Its a great concept,

    Thanks for the inventors. I also think it's quite a good way to design UIs :-)
    Why don't you try to push it into some great open source Web framework

    I'm fully in favor of this approach too !
    But I wanted to have some feedback about that stuff before. Posting here allows to get in touch with people like you, and validate everything in a first step.
    Also, this framework is not something new. It has at least 4 years (I even ask myself why nobody thought about that before !!!)... At that time, web frameworks were not so common !
    Last but not least, I'm already involved in so many things (they pay me for this !), I have to take on my personnal time to enhance the framework. No complains, I love this, but you know it's hard sometimes... so progress is quite slow. Finding poeple to partner with on that task would be great (hidden message here :-) ).

    A part from that, of course, my main wish about that would be that it's incorporated into something existing.
    like WebWork?

    Well I must admit I've never used this one. I've only read a few docs, and yes, it has some similarities in the concept...
    Just like struts, it could integrate profiling capabilities "à la JWebViews"...

    But, IMHO and with all respect that is due to existing frameworks, associated concepts and work, JWebViews goes even beyond this.
    Not only because of the profiles, even if it's something very useful, but mainly because you really deal with your *objects* in JWebViews actions, not with HTML forms ! After all, what's really important is the model.
    Actually, the strenght of struts (and such frameworks) is IMHO in the associated tools (validators, taglibs, etc.). Still, the controller mechanism is IMHO more clever in JWebViews...

    IMHO, the best web framework should provide the strongest MVC model *as well as* useful tools for the views...

    Actually JWebViews defines a clear controller mechanism, but the View is up to you... So finally it's more a story of complementary things than overlap I think.
    I don´t understand the need to redo everything end to compete with everybody.

    Fully agreed. It's not my intention no worries about this !
    But I do understand the need to do things your way in the beggining so you do not have to deal with how other people think.

    That's another true argument, yes. Also, it allowed me to test that stuff through various small-sized applications (no thousand users, mainly intranets) and get people use it (I mean develop with it)... Well, they were satisfied with this, end-users did not complain about anything (they don't see nothing about this of course), and it was the very first step to make the "proof of concept"...
    Please do not compete, try to find some already stablished framework to adopt and maintain it.

    This is the next step... BTW, have you got free time you don't know what to do with ?
    :-)

    Cheers

    Remi
  6. Implementation class[ Go to top ]

    Hi Remi,
    Do you have the implemented classed and the defined packages.If so where can I locate it for download.

    Regards
    Govindan
  7. Implementation class[ Go to top ]

    If you talk about the framework itself, everything is in the war file (includes sources, libs, docs...).

    Just download it there :
    http://www.rvkb.com/jwebviews/download/jwebviews.war

    I'm sorry I was using JB at that time, and I did not have time to port the project to Eclipse or even put it on a CVS somewhere... But it should be quite simple to rebuild everything if you want.

    One point : there is not profile repository implementation in that distro (at least a real functional one : only the demo PR is shipped with JWebViews). So you'll probably have to implement your own, based on some DB or any other data source you already have...

    One tip : try it first with a tree structure instead of a graph : modeling system actors (they usually map nicely to Profiles in JWV) is often simpler that way !!!

    Cheers

    Remi
  8. Remi:
        I've read the 1st half of the framework's overview. What I get from the reading is that you can change the action executed on an object when the user has a given profile.
        If that's the case, I was wrong with my first impression about the framework. I thouth that it was aimed to present different actions for each user. In simple words, change the "menu" you see depending on your profile. So, the admin would see every action possible, the gest just queries, and such things.
        But judging from what i've read, it I want to do that with your framework, I must CODE the "view" action, let's say, for the "menu" object. And i have to code an action for each profile. So, I would end up with ShowMenuAdminAction, ShowMenuGuestAction, ShowMenuUserAction...
        More interesting would be to have this done by the framework. Besides, it looks a bit intrusive having to:
    1) Drop every other framework in use, in order to use yours.
    2) Having to LEARN a new framework.
    3) End tied up to a framework which is not widely adopted.

    Number three represents the usual fear or duobt that cames along with every new thing, of course... ;)

        Perhaps you could enlight me? Am I understanding your framwork correctly?

        Please, feel free to email me. I'd very much like to participate, since I've given a lot of though lately to this kind of issues in J2EE apps. My address: martinstraus at hotmail dot com

        Hope to hear from you

    Cheers,
    Martin
  9. "Profile-based" MVC applications[ Go to top ]

    Sorry for the lame spelling...

    ;)
  10. Hi Martin,

    sorry for the late reply : was in deep powder of the French Alps last week :-P
    Remi:&nbsp;&nbsp;&nbsp;&nbsp;I've read the 1st half of the framework's overview. What I get from the reading is that you can change the action executed on an object when the user has a given profile.

    Well, you assign actions to *objects* and *profiles* when you design the app. The framework is responsible of getting some code (the action) and execute it for a profile (i.e. someone who's browsing) and an object...
    Example : The "client" profile can see the catalog, whereas the "admin" has additional widgets to add/remove/update products from the catalogue.
    Actions are assigned to object types (classes and interfaces) and profiles by declaration, before the application is started.
    I thouth that it was aimed to present different actions for each user. In simple words, change the "menu" you see depending on your profile. So, the admin would see every action possible, the gest just queries, and such things.

    That's it :-)
    But judging from what i've read, it I want to do that with your framework, I must CODE the "view" action, let's say, for the "menu" object. And i have to code an action for each profile. So, I would end up with ShowMenuAdminAction, ShowMenuGuestAction, ShowMenuUserAction...

    Absolutely. With the possibility to "override" an action : re-define it for a sub-profile.
    ShowMenu would then lead to 3 actions with the following keys :
    ("ShowMenu", guest_profile, x.y.z.Menu)
    ("ShowMenu", user_profile, x.y.z.Menu)
    ("ShowMenu", admin_profile, x.y.z.Menu)

    And the profiles tree would look like :

    guest_profile
      |
    user_profile
      |
    admin_profile
    More interesting would be to have this done by the framework.

    This could be handled by additional tools with no problems. Typically we could consider a GUI that allows to generate Action skels for some profiles and some objects... select types (like in eclipse's type browser), select profile (using a dedicated graph view for example), and click on a button...
    But still, you'll have to tell whant you actually want to do. The "tool" can generate skels for actions, but it of course can't know how you actually want to represent your "Menu" !

    At the moment I only got the framework itself... Many tools could help a lot to develop with it ! I do everything "by hand" because I know the framework well, but I fully agree that some eclipse plug-ins for example would be really appreciated and make development faster !!!!
    1) Drop every other framework in use, in order to use yours.

    Integrating to struts or webwork would definitly be great, but I can't tell now : I have to investigate that and it's a lot of time :-/
    But you are right, and you're not alone thinking this !

    Also, last but not least, that's what you already did when you chose struts or smth else... just dropped everything and start from scratch or almost !
    2) Having to LEARN a new framework.

    Same considerations. But still, one big advantage of JWebViews IMHO is its simplicity ! It does not adress *everything* just like Struts and WebWork ! it does not deal with taglibs, validators, redefinition of graphical components or such things ! This should be independant from the controller mechanisms IMHO, and it *is* in JWebViews.
    You can use the taglibs you want or any other library, JWebViews only handle profiled control of requests.
    It's by far more on the "controller" side than the view.
    3) End tied up to a framework which is not widely adopted.

    For sure : there must be 4 or 5 apps built on top of it in the world LOL :-)
    Number three represents the usual fear or duobt that cames along with every new thing, of course... ;)

    Agreed. Well, I'd answer something like "everything needs a beginning" I guess...
    Perhaps you could enlight me? Am I understanding your framwork correctly?

    Well, you look like yes ! :-)
    I've given a lot of though lately to this kind of issues in J2EE apps.

    Here's an appetizer then : think about a JWebViews Profile Repository that maps the appserver's roles ! This way not only "permissions" are assigned to J2EE roles, but also the representation of your objects for each of these roles !
    :-)

    Thanks for your feedback

    Cheers

    Remi
  11. Can this framework work on applications which dont have authentication? Do you handle concept of a transient profile (just a in-memory profile object since there is no profile info in the underlying db).

    For every action, do we have to define the expected input parameters and the corresponding target object? If yes, its sort of a taglib definition only. If not, where to define?
  12. Hi Tapan,

    Funny that you ask now, I'm currently porting everything sto sf... lots of coincidences over here, definitly !

    Anyway,
    Can this framework work on applications which dont have authentication?

    Yes it can, it's just about setting a param in the webapp's DD :-)
    Do you handle concept of a transient profile (just a in-memory profile object since there is no profile info in the underlying db).

    Yes the concept of a profile is actually very abstract for the framework and that's what makes it powerful too...
    Actually you (jwebviews user) are responsible for developping the Profile Repository implementation so you can do whatever you want.
    I even have a "mixed mode" in an app I'm currently developing for a client :
    Users are stored in a DB (users table) and manipulated via an Hibernate mapping, but there's no real "roles" at the moment, only "admin/not admin" (represented by a boolean in the users table).
    Since the profile repo has to model a graph, I need profiles for my "admin/standard" roles. So I represent them using in-memory Java objects (singletons since the role is unique). Of course, both roles (AdminProfile, StandardProfile) and user wrapper profiles classes implement JWebViews' IProfile, and the IProfileRepository does the cooking with all this.

    In short, the only thing to do is to provide IProfileRepostory and IProfile implementations, so that the framework can navigate the profiles graph...
    You actually do what you want there (in-memory, SQL, XML, LDAP, or whatever).

    Last but not least, one could argue for some time about the difference between "unauthenticated" and "authenticated as anonymous (or guest, visitor, etc.)"...
    You can use a JWebViews profile to represent the "anonymous" thing, and thereby make it even more coherent with the rest...
    For every action, do we have to define the expected input parameters and the corresponding target object? If yes, its sort of a taglib definition only. If not, where to define?

    Sorry I think I don't get your point. Are you talking about what you have to put in your HTML code in order to trigger action execution on the server side ?
    Tell me more please...

    BTW, it's now (partly) on jwebviews.sourceforge.net.
    Struggling to get that f*ckin' home page redirected (SFTP mysteries) but the CVS pserver checkout works.
    File release and home page should be ok tonite or at least next week.

    Have fun,

    Remi