MVC UIViewController vs UIView advice

I have an app that I originally built using 4 separate UIViewControllers so that I could have my AppDelegate call the appropriate view controller for the specific layout and view configuration.  It seemed reasonable at the time.
Now, I want the user to be able to change the layout while running the app, and it doesn't seem to make sense to dismiss the entire view controller to restart the app from the AppDelegate level.
So, I think I should split the current view controller up into parts, with the base viewController having all the common elements, and then have the variable layouts (which each have a bunch of buttons) as separate UIViews which I just read from a nib file so only one layout is in memory at a time.
I separated the UIView elements into separate .xib files, but...
The only problem with that is there doesn't seem to be an way to simply read in a UIView from a nib file to add them to the existing view controller.
For MVC, it was my understanding that you only have one VC active at a time, so using a separate viewController to read in the appropriate button layout for only one small section of the screen was not appropriate.
Am I understanding that properly, or is it perfectly fine to have one VC controlling the top and bottom of the screen, a 2nd VC to handle the button layout view on the left side of the screen and a 3rd VC to handle the text display with clipping of the view to show only a portion allowing the main background (controlled by the first VC) to show through?
Or, if only one can be active, how should I manage the individual views?
Once this is re-done, I plan to add views for the iPad, and just have to manage the views that are different between the platforms, so whatever mechanism I choose should als work for universal apps.
Thanks!

Well, I've done some more research since I posted the question, and  loadNibNamed:owner:options: seems like one method to bring in the individual UIView objects as I started to do early in this update.  (Instead of
initWithNibName:bundle: )
The examples in the Resource Programming Guide are a little sparce in this area.
I presume that once loaded from the nib file, I still need to add the view as a subView.
Alternatively, would it make the most sense to create my main view nib file including the default view with the button layouts in the default configuration, and then if/when the user selects a different layout, replace the current view with one that I load from the appropriate "alternative" nib file, freeing up the previous UIView object?
In this instance, the initial layout view will already be part of the subview  structure added with the UIViewController, and I would simply be replacing the existing UIView object with a new one from my alternate nib file.
Right?

Similar Messages

  • Label becomes nil when coming from UIView in UIViewController

    Hi,
    I'm trying to call a method in UIViewController from UIView to change the UILabel in UIViewController by passing a NSString argument from UIView. But it doesn't the UILabel becoz the UILabel becomes nil in UIViewController. But method is called properly becoz in NSLog it is showing the passed argument but not changing the UILabel. Can Somebody help in solving the issue?
    Thanks in Advance.

    Your label may not be hooked up to the vc.

  • Images and buttons

    I want to load an image onto the screen and allow the user to touch parts of the image to trigger an event.
    I can get an UIImageView with an image to load onto the screen, but it seems to hide the button I put in place with IB. How can I "hide" the image behind the button so the button will work?
    Is this easier working out of the viewcontroller object or creating a uiview object? Right now, I can only get the image to load if I use a uiview object.
    Should I define the IBAction method for the button in the uiviewcontroller or uiview?

    If you need to know where the touch occurred on the image, take darkpegusus' advice and subclass UIImageView so you can override the touch methods.
    However if you only need to know if the image was touched and don't need the location, a button would work fine and is much easier to program than a subclass.
    You asked how to hide the image. For that all you'd need to do is put a button on top of the image. You'd do that in IB by dragging a button onto the image, then going to the xib window (the window with icons such as File's Owner; if you don't see it select Window->Document). At the left end of the toolbar select ViewMode->center (the switch with 4 horizontal lines). Now expand the content view (probably the bottom icon; it won't be called content view, but it's the view that contains your image view). You should now see your UIImageView and your UIButton as children of the content view. The button will be on top of the image view when it's lower in the list. If the button isn't at the bottom of the list, drag it lower. The button may try to leave the list of children, but make sure it goes into the list (indented) at the bottom. You should now see the button on top of the image view.
    Note that the above procedure makes the button hide the part of the view under it. But I suspect you may have meant "Put the button over the image so it will respond to a touch, but hide the button". If that's what you want, you need an invisible button. You can't do this by setting the button's alpha to zero, because it will no longer respond (alpha needs to be above 0.2 before a view will respond to touch). You also can't change the background of a rounded rect button to clear. It will always be drawn white.
    For an invisible button, what you want is a "custom" type UIButton. Select the button, bring up the Attributes Inspector and at the top of the panel, change the Type to Custom. Next select the image view and bring up the Size Inspector. Write down the x, y, width, height for the image view, then select the button again and set it's dimensions to those numbers in the Size Inspector. You should now have an Invisible button which exactly covers the image view.
    Re your last questions, your UIImageView and UIButton must be added to a view (the IB editor window might be named View Controller, but when you add something to that editor window, it will be added to the controller's view, not the controller itself. I.e. whether or not you use a view controller, controls and other subview are always added to a view object as shown in the xib window.
    If you have a controller, you should "control" the button and image from the controller object. In other words, you'll have your own subclass of UIViewController with instance variables for all the controls on the content view (the view controller's view). You can specify IBOutlet for those instance vars and connect them to the correct controls in IB. Similarly, your view controller subclass should define IBAction methods for each button (or other control), and you make the connection from the buttons to the methold in IB.

  • Connect a UIView with a UIViewController

    How can I connect a UIView subclass with a UIViewController subclass with code? I know how associate a nib file with a UIViewController, but it would be nice not having to create nib files for all my view controller classes, and just create everything with code instead.

    in your UIViewController's viewDidLoad event, wouldn't you initialize your UIView class and assign that object to the view property of your view controller?
    -MrB

  • Add UIView subclass to UIViewController subclass programatically

    Hi.
    I've been trying to find out how to add a UIView subclass to a UIViewController subclass all in code with no IB.
    I've googled and searched forums but nothing seems to work for me.
    How would you go about making the most simple app that has an appDelegate, view controller, and a view?
    I load the view controller (MainViewController) and anchor it to the window in appDelegate.
    Then I make a UIView subclass (MainView) and add the class to mainViewController and create an instance of it.
    I import the .h and in the loadView method of the viewController I add this:
    [self.view addSubview:mainView];
    That doesn't seem to work and I have also tried initializing it like so:
    CGRect = screenBounds = [[UIScreen mainScreen] applicationFrame];
    CGRect = windowBounds = screenBounds;
    windowBounds.origin.y = 0.0;
    self.view = [[UIWindow alloc] initWithFrame:screenBounds];
    mainView = [[MainView alloc] initWithFrame:windowBounds];
    [self.view addSubview:mainView];
    All this results in absolutely nothing except for the white background of the view controller to show.
    Just to see if it works, I initialized the mainView's background to a greenColor;
    Any help would be much appreciated as this is the only thing preventing me from completing an app.

    Here are the .m files for a project named AllCode. I started it by removing the nib file from the Window-Based Application template:
    // main.m - since there's no nib the app delegate class must be specified here
    #import <UIKit/UIKit.h>
    int main(int argc, char *argv[]) {
    NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
    int retVal = UIApplicationMain(argc, argv, nil, @"AllCodeAppDelegate");
    [pool release];
    return retVal;
    // AllCodeAppDelegate.m
    #import "AllCodeAppDelegate.h"
    #import "MyViewController.h"
    @implementation AllCodeAppDelegate
    @synthesize window;
    @synthesize myViewController;
    - (void)applicationDidFinishLaunching:(UIApplication *)application {
    CGRect frame = [[UIScreen mainScreen] applicationFrame];
    UIWindow *aWindow = [[UIWindow alloc] initWithFrame:frame];
    self.window = aWindow;
    [aWindow release];
    MyViewController *aViewController = [[MyViewController alloc] init];
    self.myViewController = aViewController;
    [aViewController release];
    [window addSubview:myViewController.view];
    [window makeKeyAndVisible];
    - (void)dealloc {
    [window release];
    [myViewController release];
    [super dealloc];
    @end
    // MyViewController.m
    #import "MyViewController.h"
    #import "MyView.h"
    @implementation MyViewController
    @synthesize label;
    - (void)loadView {
    CGRect frame = [[UIScreen mainScreen] bounds];
    self.view = [[MyView alloc] initWithFrame:frame];
    - (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor lightGrayColor];
    CGRect rect = CGRectMake(100, 210, 120, 21);
    UILabel *aLabel = [[UILabel alloc] initWithFrame:rect];
    self.label = aLabel;
    [aLabel release];
    label.text = @"Hello World!";
    label.textAlignment = UITextAlignmentCenter;
    label.backgroundColor = [UIColor clearColor];
    [self.view addSubview:label];
    - (void)dealloc {
    [label release];
    [super dealloc];
    @end
    Edit Info.plist to remove the Main nib file base name--i.e. just delete the default name to leave that field blank--and you should be good to go.

  • How to load a UIView when a button clicked ? With a UIViewController ?

    Hi,
    I have a view controller which is loaded in a Window at the launch of the application. But I would like to load a UIView when I click on a button.
    I have the files below :
    - simpleAppDelegate.h
    - simpleAppDelegate.m
    - mainViewController.h
    - mainViewController.m
    How can I do with Xcode and IB ?
    Thank you a lot !
    Message was edited by: @pocalyps0

    If you want to display a second, full-screen view which has its own view controller I would recommend studying the Utility Application template (Xcode File->New Project...). This is a very instructive template and your time will be well spent even if your goal requires a different behavior.
    If you just want a smaller subview to appear on your main view, you can add a UIView in IB just as you would add a UILabel or UIButton, and change its hidden property in your code. If you'd rather not create the subview until it's needed and/or you want it to have it's own view controller, you may want to define it in a separate nib file and your study of the Utility template will probably help you see how to do this.

  • IPhone SDK Beta 2 Interface Builder Add a UIViewController

    Hi,
    I am trying the new SDK (beta 2). I didn't try the beta 1 before, because of the lack of IB. However, I am having a problem when trying to code a simple Hello World with a button, with a classic MVC design.
    If I use a UIViewController as a view controller, it compiles fine, but when I hit the button, it crashed. If I code it, or if I subclass the UIView and use it as a view controller, it works.
    Is there any difference of coding compared to a "classic" cocoa app ?
    I hope everything is clear.
    Thanks for your help.
    Have a great day.

    scottjg wrote:
    I've written a tutorial on how to setup a basic Hello World MVC app at: http://ihatetheiphonesdk.blogspot.com
    hope it helps!
    thanks. That helped me!
    A couple of issues though:
    1. I could not "*right click*" and bring up the outlet popups. I had to control-click to do that.
    2. the steps for connecting up outlets for viewController and window did not exist already for me as selectable outlets
    "-Connect our App Delegate's viewController outlet to our view controller, and the window outlet to our window:"
    I added them manually to the app delegate and then ran the connections. Then, I had to add
    +" IBOutlet UIWindow *window;+
    +IBOutlet UIViewController *viewController;"+
    to my HelloWorldAppDelegate.h file (along with any other code that I compared to your files)

  • Need help and advice on designing relations of classes

    I tried to use JInternalFrame which contains an extension of JPanel as the UI content (with actionListener for the buttons inside it). The Panel is contained in a JScrollPane.
    jIntFrm = new JInternalFrame("-Title-", true, true, true, true);
    jIntFrm.setLayout(FlowLayout());
    jIntFrm.add(new JScrollPane(new PnlEntry()));
    The user clicked the button inside the panel (PnlEntry) to close the JInternalFrame containing this panel or another button to do operations that will need to display another JInternalFrame containing another extension of JPanel.
    Please give me advices on how these should be done, so that it makes good OO relations.
    Right now, I'mdoing it like this:
    public class mainFrame extends JFrame{
    JInternalFrame jIntFrm; //AND OTHER INTERNAL FRAME
    jIntFrm = new JInternalFrame("-Title-", true, true, true, true);
    jIntFrm.setLayout(FlowLayout());
    //THE PANEL IS GIVEN THE REF AND MEMORIZE IT UNTIL IT
    //INVOKES mainFrame.panelExit(JInternalFrame)
    jIntFrm.add(new JScrollPane(new PnlEntry(this, jIntFrm)));
    panelExit(JInternalFrame jif){
    if(jif == jIntFrm){
    jIntFrame.dispose();
    jIntFrame = null;
    panelContinueProcess(JInternalFrame jif, Object someID){
    if(jif == jIntFrm){
    jIntFrame.dispose();
    jIntFrame = null;
    //start displaying another JInternalFrame with the appropriate Panel in it
    Is this all is OK?
    Please give me your advice
    Thx,
    David

    Maybe read on MVC (Model-View-Controller) pattern? It's practically the standard for Swing applications (even Swing itself follows the pattern).
    You don't want to clutter your frame with behavioral code.

  • Cocoa app design advice

    hello,
    as i'm studying cocoa i've created a test app and i'm looking for some advice/direction when it comes to design. this is what i've done so far:
    1. placed a custom view on my main window linked to my custom subclass "dropview" of nsview
    2. placed a table view on my main window linked to a "appcontroller" object
    with the custom view i can accept drags and when i do i use a nstask method to search for files and place these files in an array. then i want to display these files in my table view. here are my questions: since the array variable is defined in my nsview subclass what is the right way to send that information to my appcontoller object? so far i have made a declaration of this variable above the @interface dropview and used #import dropview.h in my appcontroller.m file. then when the app launches it tries to set the table view from the start before my array variable is defined, but once the array variable is defined how do i tell the table view to update? i have tried to tell my table view to reloaddata from my dropview class but the table view is linked to my appcontroller class. i hope this makes sense and any advice on how i will communicate between the 2 classes is greatly appreciated!
    thank you,
    rick

    You should create one servlet, which accepts the params of any form and passes them to the backend.
    In summary:
    The one servlet is a 'controller' servlet ( the 'C' in MVC design).
    It takes in all url requests for all JSP pages (never allow a user to directly call up a JSP page) or from a submit from a form tag on any JSP page, or from a click on a hyperlink. It verifies the person is logged in (authenticated) and has permission to view the JSP page it wants to view (authorization). If its not authenticated or authorized, it dispatches to an error page. If it is, it determines what JSP page the request is comming from and what it wants (example: update button was clicked). It then instansiates business logic and sends the JSP page's information to it. The business logic performs the work. The data coming back from the business logic is put in request scope by the servlet (not by the business logic) and the servlet dispatches to the appropriate JSP page (which will get data out of request scope to be displayed).

  • Looking for advice on what which freamework or dev. methodology for read only database centric web application

    Hello, I hope the experts here can advise me on which development approach for a new .net web application that  I am to begin development shortly.  I have the back end stored procedures complete and now I will build a .net front end. 
    This front end will be 95% populating custom html5/css3/jquery pages from c# DataSets which are themselves populated from calls to oracle stored procesures.  There will be no updating - this is read-only querries of OLTP prpared tables off of a data
    warehouse schema.  I am a verteran at the back end stuff but my web app development skills are new so I hope to get a recommendation form the experts on what approach I should persue to build the front end.  From what I have seen I might start
    with MVC5 framework and build the web pages with RAZOR embedded c# code looping through the DataSets to create the html. I need to the ability to create very custom div elements throughout, so I understand I should not use some high level code generation
    tool.  Thanks so much for the feedback. 

    Hello Jay,
    This forum is discuss and ask questions about the C# programming language, IDE, libraries, samples, and tools.
    >>I hope the experts here can advise me on which development approach for a new .net web application.
    From this message, you are doing web applications, you will need to post this thread to Asp.Net  forum for some advices. For MVC issues, please post
    Here.  Thanks for your understanding.
    Have a nice day!
    Kristin
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • Life after InfoPath - seeking advice

    So we currently have a SP2010 environment where we have made extensive use of InfoPath forms. Some basic, some are centrally published with lots of code. Our new Director is hot on SharePoint Online and wants us to investigate moving to the cloud. Hoping
    to get some direction/advice here.
    If we were to ignore that InfoPath is going away, and keep using it while we can, forms with code cannot be published to SharePoint online, right?
    If we decide to do everything in aspx, will our devs who have worked primarily in InfoPath need to ramp up on asp.net, html, css, javascript, all without the benefit of a visual editor?
    Can we use asp.net technologies like webforms or mvc in SharePoint 2013 Apps?
    Am I missing other options?
    Thanks

    First piece of advice.  Don't panic.  InfoPath is guaranteed to be around for the next 10 years.  At this point Microsoft is working on several alternative products and until they announce the completion of the alternatives its too early to
    stop using InfoPath if you have been using it.  The alternatives aren't ready yet. The answers to your other questions below:
    If we were to ignore that InfoPath is going away, and keep using it while we can, forms with code cannot be published to SharePoint online, right?  - Correct, no code behinds for forms in SharePoint Online
    If we decide to do everything in aspx, will our devs who have worked primarily in InfoPath need to ramp up on asp.net, html, css, javascript, all without the benefit of a visual editor? - For 2013 I think that is a fair statement.  If they use
    Visual studio there is the ability to do a Visual Web part, which includes a visual editor, but I think you get a better result without it.
    Can we use asp.net technologies like webforms or mvc in SharePoint 2013 Apps?
    Yes.  Its just that Apps are basically going to be limited to client side code like javascript and won't be able to use server side code like C# code behinds (except for provider hosted apps which don't run on the SharePoint server so they can't use SharePoint
    server API anyway.)
    Hope that helps
    Paul Stork SharePoint Server MVP
    Principal Architect: Blue Chip Consulting Group
    Blog: http://dontpapanic.com/blog
    Twitter: Follow @pstork
    Please remember to mark your question as "answered" if this solves your problem.

  • MVC - Organizing models and managing GUI windows

    I'm having difficulty organizing my MVC models and basically controlling the whole application in general. My application works, but all the controlling logic is being dumped into the main class (Main.java). Here's a simple example of the problem I'm having:
    Objectives
    1) Display a list of Companies; i.e. Sun, Microsoft, Adobe, etc. (JFrame with a JList)
    2) The user select a Company and it pops up a new dialog with a list of Employees. (JDialog with a JList)
    Here are the classes I came up with:
    Models:
    1) CompanyListModel
    2) EmployeeListModel
    Listeners:
    1) CompanyListener
    Views:
    1) CompanyListFrame
    2) EmployeeListDialog
    Domain Objects:
    1) Company
    2) Employee
    And then there's the main application class. To implement the above objective, I've been using my main class to control the GUI.
    Here's an example of how I've implemented it.
    public class Main implements CompanyListener {
        /** Creates a new instance of Main */
        public Main() {
            CompanyListModel companyModel = new CompanyListModel();
            companyModel.addCompanyListener(this);
            CompanyListFrame gui = new CompanyListFrame(companyModel);
        // A company was selected.  Open a new dialog and display the employees
        public void companySelected(CompanyModel companyModel) {
            Company company = companyModel.getCompany();
            EmployeeListModel employeeModel = new EmployeeListModel(company));
            EmployeeListDialog = new EmployeeListDialog(employeeModel);
        public static void main(String[] args) {
            new Main();
    }My program is similiar design wise to the above, but contains many more classes. I'm still using my main class to control GUI logic (popping up new windows and creating models, etc). Thus, my main class implements like 5 different listeners. I'm sure this is a really poor design choice, I just don't know how else to implement it.
    I should not nest models... correct? I was thinking about nesting the models, i.e. CompanyListModel contains an EmployeeListModel, but then the CompanyListModel will need to spawn the EmployeeListDialog when a Company is selected, right? Thus, I'd be mixing the view with the model.
    Please provide some advice! :( Thanks!

    I'm sorry, I read your reply about 3 times and I've
    spent the last 20 minutes trying to implement it.
    I'm just not sure how the controllers are involved.
    Could you possibly provide source code for the
    controllers (and any part of the models / views that
    communicate with the controller)?No source code. Read about the MVC pattern.
    I feel like this is a wasted effort. I'm the sole
    entry level programmer at my company and I have only
    one year real wold experience . I work with about 10
    other senior level (microsoft) programmers and none
    of them code in this fashion. All of our
    applications are desktop applications using C#,
    C/C++, or scripting languages.What's a wasted effort? You posting a question? Me posting a response? You writing Java? You trying to think about how to do this properly?
    So why are you using Java if you're in a Microsoft shop? How's this working out with your co-workers?
    I feel like if I worked on a project with one of
    them, they would criticize me for using MVC and
    "complicating" such a simple issue.That's usually because Microsoft likes tying a particular text box to a column in a table. If you change the textbox value you change the database. Nice and easy, right?
    In trying to implement this solution, my workspace
    now has a huge load of classes for something so
    simple:
    Company
    CompanyFrame
    CompanyListController
    CompanyListListener
    CompanyListModel
    CompanyListPanel
    Employee
    EmployeeListDialog
    EmployeeListModel
    EmployeeListPanel
    Main
    11 classes and I left out the Emp Controller and
    Listener to simplify the example. The more classes
    that you have, the slower the application startup
    time. Moving the Views to JPanels as you suggested
    seemed smart but it wound up making it more
    difficult. I'm using NetBeans and Matisse and I
    don't believe you can use another JPanel class in the
    GUI editor unless you make it a bean.
    Traditionally, I would have implemented as follows.
    I would have completed it in 5 minutes and it would
    be much easier to understand what's going on:
    Company
    CompanyFrame - contains a list of companies
    Employee
    EmployeeListDialog - contains a list of employees
    Main
    Of course doing it this way I'd be mixing data with
    the view, but is that always a bad thing or is it
    only bad for large scale applications? Should MVC
    not be used for small modules like this?For small modules that are nothing more the CRUD operations, it might be that a simpler approach is fine. (PS - CRUD stands for Create/Read/Update/Delete, standard relational operations on tables. I'm not commenting on you or your code.)
    It only becomes a problem when that "simple" CRUD application decides to branch into something bigger. The approach of mingling view and data can become problematic then.
    It's still possible to have a clean application for small apps. I think most Microsoft programmers do it that way because the wizards and stuff they're used only allow it to be done that way.
    The reasons why I'm going away from my old "academic"
    programming practices is:
    1) I want to become a better programmer of course!Kudos to you. At least you're still thinking about it.
    2) There's alot of database queries in this
    application so I wanted to separate that from the GUI
    as much as possible. Thus, each model knows how to
    query the database and it's all done on separate
    threads.That's good motivation, too.
    I'd really like to do this right. If you could
    provide source that would be great. Also, are there
    any good books on desktop GUI development geared
    towards Java (or even C#)?I don't write for the desktop, so I'm not much help.
    I already purchased the e-book Desktop Java Live,
    which is great but they don't go into detail about
    MVC and instead use Model-Presenter which has been
    retired (according to Fowlers website). I found that
    section fairly confusing so I figured I'd start with
    MVC since it's more widespread (?).If you're reading Martin Fowler you're doing well.
    Thank you.I'm sorry that I'm not more helpful.
    %

  • Looking for opinions, flow logic versus MVC

    We are about to start our second major BSP project, so we are relatively new at BSP. Our first project was stateful, MVC driven, and works great. The new application will have up to 50 simultaneous users doing very quick asynchronous tasks (data collection, essentially) but where i want to maintain a session, and so i am making it stateless so the resources are not tied up and using a backing table in SAP to hold state information combined with client side cookies.
    My question is, in a stateless environment, what if any advantage is there to using MVC? It seems like a lot of work to maintain the model for each session request. Is it normal to use MVC for both stateful and stateless, or is flow logic more standard for stateless? I looked around quite a bit in the WIKI, blogs, etc, and dont really see a lot of examples using MVC that are stateless.
    Any advice here would be appreciated, before we chase ourselves down a hole.

    Hi David,
    I totally agree with you that MVC gives you nothing for stateless applications.
    When I build BSP applications I try to always...
      .... go stateless
      .... use page model - not MVC
      .... assign application class and do all backend processing there
    For persistence I typically use server-side cookies - these are managed by the CL_BSP_SERVER_SIDE_COOKIE class.
    In my application class I get the server-side cookie in the IF_BSP_APPLICATION_EVENTS~ON_REQUEST method and I save it in the IF_BSP_APPLICATION_EVENTS~ON_RESPONSE method.
    The appropriate checking of a sequence number on the server-side cookie can mitigate against users hitting refresh buttons, back buttons, etc.
    Cheers
    Graham Robbo

  • How to program navigation in a MVC application? (help please!!)

    Hi,
    I´m exploring how to develop a BSP application with MVC.
    SO far I have a ´page´ composed by a controller, 2 or more sub-controllers and their respective views.
    But I want an application consisting of many pages.. So here I am, in my DO_HANDLE_EVENT method wandering what to do when I want to redirect the user to a new page. I guess there´s two options here:
    1) change the subcontrollers/views for the new one. (using controller_set_active or controller_delete..?)
    2) redirecting to the new page with navigation->goto_page( 'page2.do' ).
    I like the second option, but there´s a problem: all my model instances die!! How can I keep them alive? How can I keep data (objects) alive from the moment a user opens the first page till he logs off the aplication??
    (I tried using the application class, but I just can´t access it using MVC, guess it´s only available from pages with flow logic)
    I truly need a hint on this! Any suggestions are most welcomed!

    Hi Mariana,
    I think the most important advice is to never jump
    directly via goto_page(). As you have noted, this way
    you lose your context. Myself I use the following
    approach:
    1) There is a strict controller hierarchy. The topmost
       controller holds your application data.
    2) In the view of the topmost controller its
       subcontrollers are called via
          <bsp:call url="sub.do" comp_id="yourchoicehere" >
                   <bsp:parameter name = "mode"
                                  value = "<%=mode%>" />
          </bsp:call>
       where "mode" is an attribute of the view which holds
       the information in which state of processing your
       application is.
    3) In the controllers in the DO_REQUEST methods
       you call its views by
       dispatch_input( ).
       l_main_view = create_view( view_name = 'main_view.htm' ).
      l_main_view->set_attribute( name = 'mode' value = mode ).
      call_view( l_main_view ).
      The dispatch_input method is only needed in the
      topmost controllers.
    4) Navigation is done by events which are passed
       automatically to the DO_HANDLE_EVENT method of
       the controller.
       IF htmlb_event IS BOUND.
          CASE htmlb_event->server_event.
            WHEN 'YOUREVENTHERE'.
    5) To understand how things work you should set
       breakpoints in all DO_HANDLE_EVENT and DO_REQUEST
       methods. You will see how events got passed upwards
       the controller hierarchy and how controllers call
       their subcontrollers.
    6) Further hint: Pass all parameters by controller
       and view attributes.
    Hope that helps.
    Joachim

  • Seeking advice for a self-teaching programme of new Java techs

    Hello,
    after a few years of technically poor projects (I learnt a lot in terms of process, quality, and non-Java technologies, by the way), I'd like to catch up with mainstream Java development.
    I am preparing a programme to learn a few technologies I have missed over the past years. I plan to develop a couple of utilities (simple CRUD apps) on my spare time, gradually including bits and bits of the bricks I want to grasp.
    I need some advice though to make this learning effective.
    My first priority is to invest in reusable knowledge, so I will stick to "standard" bricks, and will aim mostly at off-the-shelf tools that work out of the box
    (for example, I don't want to spend hours to fix a DB install&configuration issue, as I know I will probably never be paid for that kind of job).
    Specifically, the technologies I plan to embrace are:
    * Java SE 5 and 6
    * jUnit 4
    * Spring
    * EJB 3 & JPA
    * Web UIs
    Here are the points where you might help me:
    * JDK 1.5 vs 1.6
    No real doubt here, the biggest language gap was introduced by 1.5. If I'm correct, 1.6 essentially brings new APIs; as long as those APIs are not my primary target (I'll try them only after I've completed my first round of catch-up :o), I am not missing much language-wise, am I correct?
    I could also jump directly to 1.6, ignoring its new APIs, and concentrate on
    1.5 language features, but the risk is stability (losing time with a 1.6 beta bug).
    * jUnit 4
    Nothing special, except I have practically read nothing about it on these forums (contrast this with TSS, where there are regular threads disputing the relative merits of jUnit vs TestNG).
    Is v4.0 a non-event? It seems to bring some niceties (mark test components using annotations), but how much comfort did it bring to those of you who have used it over jUnit 3.8.1?
    * Spring
    Leaving aside that it's on my must-do list, I actually wonder which version I should try?
    I also feel I should try it first on a non-EJB app, to avoid mixing concerns. I will skip the JDBC wrapping API though, as I already have a lot to do with other persistance APIs.
    Any feedback?
    * EJB3/JPA
    (I formerly worked with generation 2.1 of the EE specs)
    1) The biggest issue here is to find a reliable EJB3 container.
    * I've heard JBoss is EJB3-ready, but I don't think it's certified yet.
    * Project GlassFish (Sun-driven open-source JEE5 container) is still in the making
    * Sun SASP9 is, well, released, but I don't know how much of JEE it supports, and haven't investigated into the licensing details yet
    Any feedback on what you're using as a JEE5 container?
    2) As far as EJB vs JPA goes, I also have the plan to use the persistence API
    outside of EJB (likely, I will develop the same simple CRUD app twice,
    once as a Webapp and once as as Swing app, both over the same DB schema).
    But maybe this is pointless, as the entity annotations and API are agnostic; have you experienced some difference that deserve thorough learning?
    3) Obviously I will need a DB. If the EJB container includes one, fine, at least for the EJB part, otherwise I'll need to install and configure one, that will need to run on a desktop PC on MS WIndows, and preferrably include a handy SQL client console for manual verification.
    I know enough of SQL to build even a sub-optimal application schema. However I know nothing of a DB administration, and I don't want to invest in that direction.
    Any advice as to a simple off-the-shelf free DB that runs on Windows?
    * Web UIs
    The dilmena here is two-fold:
    1) In term of "view" technology, I hesitate between plain JSP and JSF
    If I understand correctly, JSF is a specification for reusable view components.
    My local job market leaves me no oportunity to be a UI component developer, whereas I am more likely to someday be tasked to integrate 3rd-party UI components into a business project.
    Is my surface understanding of JSF correct? In this case, how much of JSF should I know if I don't have to develop JSF components?
    2) In terms of controller, as part of my Spring learning, I'll probably have a look into Spring MVC.
    My question is, how much of the servlet/JSP API does springMVC show/hide?
    Is it a good idea to use springMVC to learn servlets and JSPs, or should I stick to manual servlet+JSP?
    I should add that I've worked with servlets/JSPs formerly (as of J2EE 2 or 3),
    I only need to dig new servlet/JSP features.

    Jim_Found wrote:
    okay, so normally you would write the following if-elseif block in order to achieve this
    if (MessageType.TYPE_A.equals(myMessageType)) {
    // do this
    } else if (MessageType.TYPE_B.equals(myMessageType)) {
    // do that
    } else if ...
    but, if you use <this design pattern> and create this <class>, you can suppress the above block to
    CoolClass coolObj = new CoolClass();
    coolObj.doMagic(myMessage);Funny enough inside the doMagic() method would be something along the lines of
    if (MessageType.TYPE_A.equals(myMessageType)) {
    // do this
    } else if (MessageType.TYPE_B.equals(myMessageType)) {
    // do that
    } else if ...Mel

Maybe you are looking for

  • IPod doesn't sync with iTunes at all...

    I'm having trouble with my iPod is because it does not sync with the computer. I assume the iPod doesn't recognize it somehow. I've tried to manually manage music and videos but when it told me to disconnect, the box was not checked. Awhile back, I d

  • CHaRM-Is that possible to create multiple Transport Request in UC

    HI Gurus, Quick question on ur.gent correction using Solution Manager CHaRM in EHP1. Is it possible to create multiple transport request(TR) for single ur.gent correction (UC). DO NOT confuse with transport task. For example, after I created transpor

  • How to add criteria to a Prompt?

    Wondering if anyone here knows of a way to limit what can be entered into an Edit Box Prompt? We have a prompt that sets a presentation variable, that then is used as a filter on the report. To limit what comes back, we would like to only allow the u

  • Power Button Sleep Function

    Hi everyone In the last couple of days I cannot sleep the computer by pressing the power button on the back of the unit - when I do this there is no response. However it will sleep as normal using the Apple Menu. This is on an iMac G5 20", PPC Rev B

  • IPhone new feature request

    I don't know where to submit a new feature request, so posting it here. Please refer me to a more appropriate site, if available. Thanks in advance. iPhone currently allows up to 16 application icons per home screen. With more and more useful apps in