Real Model View Controller with JTextField

Hi!
I am new to Java (so please bear with me). I am building a swing application. I already have added a JTable with a corresponding table model that extends AbstractTableModel. Rather than store the data in the table model, I have modified setValueAt and getValueAt to write and read cell data to another location. So far, everything is fine. When doing setValueAt, I have a fireTableCellUpdated statement that I use to update the edited cell. So far, things are all still fine.
I would like to do the same thing with a JTextField. I found an example in Core Java Volume 1 for create a class that extends PlainDocument. It uses insertString to update the document in a way that ensures that only numbers are entered. I implemented this. Everything is still fine. I changed insertString to update my remote repository (a field in another class). Everything is still fine. Next, I tried to change (override) both getText methods to read from the repository. This works, but is not reflected on the screen.
I realize that I need the equivalent of a fireTableCellUpdated statement for the class that extends PlainDocument, but do not know how to do this.
I have looked a lot over the internet for the model view controller implementation. I know that it can be done using event and event listeners, but this seems to defeat the purpose of the model view controller - it seems like you ought to be able to directly modify the model object to access external data.
My code is below.
Thanks/Phil Troy
* PlainDocument class to make it possible to:
* - Make sure input in unsigned integer
* - Automatically save data to appropriate locate
* This will hopefully eventually work by overriding the insertString and getText methods
* and creating methods that can be overridden to get and save the numerical value
class UnsignedIntegerDocument extends PlainDocument
     TutorSchedulerPlusSettings settings;
     JTextField textField;
     public UnsignedIntegerDocument(TutorSchedulerPlusSettings settings)
     {     super();
          this.settings = settings;
     public void setTextField(JTextField textField)
     {     this.textField = textField;
     // Overridden method
     public void insertString(int offs, String str, AttributeSet a) throws BadLocationException
     {     if (str == null) return;
          String oldString = getText(0, getLength());
          String newString = oldString.substring(0, offs) + str +oldString.substring(offs);
          try
          {     setValue(Integer.parseInt(newString));
               super.insertString(offs, str, a);
               fireInsertUpdate(new DefaultDocumentEvent(offs, 10, DocumentEvent.EventType.INSERT));
          catch(NumberFormatException e)
     public String getText()
     {     return String.valueOf(getValue());
     public String getText(int offset, int length) throws BadLocationException
     {     String s = String.valueOf(getValue());
          if (length > 0)
               s = s.substring(offset, length);
          return s;
     public void getText(int offset, int length, Segment txt) throws BadLocationException
     {     //super.getText(offset, length, txt);
          char[] c = new char[10];
          String s = String.valueOf(getValue());
          s.getChars(offset, length, c, 0);
          txt = new Segment(c, 0, length);
     public String getValue()
     {     int i = settings.maxStudents;
          String s = String.valueOf(i);
          return s;          
     void setValue(int i)
     {     settings.maxStudents = i;
}

Hi!
Thanks for your response. Unfortunately, based on your response, I guess that I must not have clearly communicated what I am trying to do.
I am using both JTables and JTextFields, and would like to use them both in the same way.
When using JTable, I extend an AbstractTableModel so that it refers to another data source (in a separate class), rather than one inside of the AbstractTableModel. Thus the getValueAt method, getColumnCount method, setValueAt method, . .. all call methods in another class. The details of that other class are irrelevant, but they could be accessing data from a database (via JDBC) or from other machines via some other communication mechanism.
I would like to do exactly the same thing with a JTextField. I wish for the data to come from a class other than an object of type PlainDocument, or of any class that implements the Document interface. Instead, I would like to use a class that implements the Document interface to call my external class using methods similar to those found in AbstractTableModel.
You may ask why I would like to to this. I have specific reasons here, but more generally this would be helpful when saving or retrieving parameters set and displayed in a JTextField to a database, or when sharing JTextField to multiple users located on different machines.
As to whether this is real MVC or not, I think it is but it really doesn't matter.
I know that I can accomplish what I want for the JTextField using listeners. However, I would like my code for the JTables to be similarly structured to that of the JTextField.
Thanks/Phil Troy

Similar Messages

  • Update methode in model-view-controller-pattern doesn't work!

    I'm writing a program in Java which contains several classes. It must be possible to produce an array random which contains Human-objects and the Humans all have a date. In the program it must be possible to set the length of the array (the number of humans to be produced) and the age of the humans. In Dutch you can see this where is written: Aantal mensen (amount of humans) and 'Maximum leeftijd' (Maximum age). Here you can find an image of the graphical user interface: http://1.bp.blogspot.com/_-b63cYMGvdM/SUb2Y62xRWI/AAAAAAAAB1A/05RLjfzUMXI/s1600-h/straightselectiondemo.JPG
    The problem I get is that use the model-view-controller-pattern. So I have a model which contains several methodes and this is written in a class which inherits form Observable. One methode is observed and this method is called 'produceerRandomArray()' (This means: produce random array). This method contains the following code:
    public void produceerMensArray() throws NegativeValueException{
         this.modelmens = Mens.getRandomMensen(this.getAantalMensen(), this.getOuderdom());
    for (int i = 0; i < this.modelmens.length; i++) {
              System.out.println(this.modelmens.toString());
    this.setChanged();
    this.notifyObservers();
    Notice the methods setChanged() and notifyObservers. In the MVC-patterns, these methods are used because they keep an eye on what's happening in this class. If this method is called, the Observers will notice it.
    So I have a button with the text 'Genereer' as you can see on the image. If you click on the button it should generate at random an array. I wrote a controller with the following code:
    package kristofvanhooymissen.sorteren;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    /**Klasse GenereerListener.
    * @author Kristof Van Hooymissen
    public class GenereerController implements ActionListener {
         protected StraightSelectionModel model;
         /**Constructor.
         *@param model Een instantie van het model wordt aan de constructor meegegeven.
         public GenereerController(StraightSelectionModel model) {
              this.model = model;
         /**Methode uit de interface ActionListener.
         * Bevat code om de toepassing te sluiten.
         public void actionPerformed(ActionEvent arg0) {
         this.model=new StraightSelectionModel();
         try{
         this.model.produceerMensArray();
         } catch (NegativeValueException e){
              System.out.println("U gaf een negatieve waarde in!");
         this.model.setAantalMensen((Integer)NumberSpinnerPanel.mensen.getValue());
         this.model.setOuderdom((Integer)NumberSpinnerPanel.leeftijd.getValue());
    StraighSelectionModel is of course my model class. Nevermind the methods setAantalMensen and setOuderdom. They are used to set the length of the array of human-objects and their age.
    Okay. If I click the button my observers will notice it because of the setChanged and notifyObservers-methods. An update-methode in a class which implements Observer.
    This method contains the follow code:
    public void update(Observable arg0,Object arg1){
              System.out.println("Update-methode");
              Mens[] temp=this.model.getMensArray();
              for (int i = 0; i < temp.length; i++) {
                   OnbehandeldeLijst.setTextArea(temp[i].toString()+"\n");
    This method should get the method out of the model-class, because the produceerRandomArray()-methode which has been called by clicking on the button will save the produce array in the model-class. The method getMensArray will put it back here in the object named temp which is an array of Mens-objects (Human-objects). Then aftwards the array should be put in the textarea of the unsorted list as you could see left on the screen on the image.
    Notice that in the beginning of this method there is a System.out.println-command to print to the screen as a test that the update-method has been called.
    The problem is that this update method won't work. My Observable class should notice that something happened with the setChanged() and notifyObservers()-methods, and after this the update class in the classes which implement Observer should me executed. But nothing happenens. My controllers works, the method in the model (produceerRandomArray() -- produce random array) has been executed, but my update-method won't work.
    Does anyone has an explanation for this? I have to get this done for my exam an the 5th of january, so everything that could help me would be nice.
    Thanks a lot,
    Kristo

    This was driving me nuts, I put in a larger SSD today going from a 120GB to a 240GB and blew away my Windows Partition to make the process easier to expand OS X, etc.  After installing windows again the only thing in device manager that wouldn't load was the Bluetooh USB Host Controller.  Tried every package in Bootcamp for version 4.0.4033 and 5.0.5033 and no luck.
    Finally came across this site:
    http://ron.dotsch.org/2011/11/how-to-get-bluetooth-to-work-in-parallels-windows- 7-64-bit-and-os-x-10-7-lion/
    1) Basically Right click the Device in Device manager, Go to Properties, Select Details tab, Choose Hardware ids from Property Drop down.   Copy the shortest Value, his was USB\VID_05AC&PID_8218 
    2) Find your bootcamp drivers and under bootcamp/drivers/apple/x64 copy AppleBluetoothInstaller64 to a folder on your desktop and unzip it.  I use winrar to Extract to the same folder.
    3) Find the files that got extracted/unzipped and open the file with notepad called AppleBT64.inf
    4) Look for the following lines:
    ; for Windows 7 only
    [Apple.NTamd64.6.1]
    ; No action
    ; OS will load in-box driver.
    Get rid of the last two lines the following:
    ; No action
    ; OS will load in-box driver.
    And add this line, paste your numbers in you got earlier for USB\VID_05ac&PID_8218:
    Apple Built-in Bluetooth=AppleBt, USB\VID_05ac&PID_8218
    So in the end it should look like the following:
    ; for Windows 7 only
    [Apple.NTamd64.6.1]
    Apple Built-in Bluetooth=AppleBt, USB\VID_05ac&PID_8218
    5) Save the changes
    6) Select Update the driver for the Bluetooth device in device manager and point it to the folder with the extracted/unzipped files and it should install the Bluetooth drivers then.
    Updated:
    Just found this link as well that does the same thing:
    http://kb.parallels.com/en/113274

  • WebCenter Sites and Model–view–controller (MVC) framework

    A customer of our started developing their sites using Webcenter Sites, they want to support additional functionality such as transaction management, exception handling, custom logging and so on. I was wondering if anyone has experience with the Model–view–controller (MVC) framework, they consider it an ideal candidate for these features. Has anyone here used the MVC framework in conjunction with WebCenter Sites to write additional java classes, facade layers and utilize the Spring controller to wire the same ? Are you aware of any other options available for this purpose ?
    regards,
    Pietro

    Hi Pietro -
    Using Sites IN a MVC framework is very difficult, because the entire context of WebCenter Sites is burned into the COM.FutureTense.Servlet.SContentServer servlet.  You can't really work around that with any degree of reliability.  Unfortunately, that means that dropping Sites into a pre-existing third party MVC framework doesn't really work. 
    There are a lot of good reasons for that, not the least of which is the two-tiered pagelet-level caching system that makes Sites so very fast at delivery... not that it's any consolation.
    To deal with this some former colleagues of mine and I built the GST Site Foundation ("GSF") framework, which provides a Spring-like MVC container WITHIN sites, instead of the other way around.  If you're familiar with Spring, you'll see patterns similar with the GSF.  My current team and I have blogged about this extensively:
    What is this whole GST Site Foundation thing? | Function1
    Create a Simple "Contact Us" Form with GSF | Function1
    How to Add Your Own DAO to the GSF Actions | Function1
    The full stream is here:  GSF | Function1
    But ultimately, the special sauce is the following: in Sites, create an XML element that contains nothing but a <FTCS> tag, a <CALLJAVA> tag, and a closing </FTCS> tag.  Your CALLJAVA will then call a class that implements the Seed or Seed2 interface, and from in there you have access to the (properly managed) ICS object where you can do all of your magic.  You can then build a lightweight controller here to handle any action you can dream up:
    https://github.com/dolfdijkstra/gst-foundation/blob/master/gsf-wra/src/main/java/com/fatwire/gst/foundation/controller/A…
    Let me know if I can help!
    Regards,
    Tony

  • Storyboard doesn't contain a view controller with identifier 'myViewController'

    I have 3 view controllers on storyboard. One of them has Storyboard Id as 'myViewController'. its runs perfectly on simulator. But when I try to run it on my device it gives following error:
    'Storyboard (<UIStoryboard: 0x1cd626d0>) doesn't contain a view controller with identifier 'myViewController''
    Please help me out with this.

    I'm not sure how "new" you are to Xcode and IB, but just double checking -- did you create the XIB file from Xcode (so that it was added to your project?). Or, if not, did you save it to your project directory somewhere and were prompted to add it to your project? If you created it new from IB it may not be part of your project yet. That's when I have seen my classes missing from the drop down menu on the Identity Inspector.
    One final thing -- after setting File's Owner, I don't see from your code how you are actually loading the NIB file (xib file). You are calling plain "init" in your app delegate where you create these view Controllers. You need to call the "initWithNibName" method. It is the designated init method for view controllers that load their interface from a NIB file.
    Cheers,
    George
    Message was edited by: gkstuart

  • Model View Controller design question

    Hi,
    I am creating a brand new web application, and would like to use the Model View Controller design (using Beans, JSP, and Servlets).
    I am looking design suggestions for handling page forwarding. I don't want to post to a jsp, and I don't want to hard code the name of the next jsp on the forward or in the servlet. I was thinking of having a properties or xml file, which lays out the routing read by the servlet and then dispatched.
    Does anyone have any other design suggestions on the best way to handle routing someone through a web application?

    What you can do is create a servlet that initializes the mappings on startup...create a hashtable of mappings from a file. You'll have to parse the file, so you can either use XML and use a SAX parser, or your own format (name=path? ie. order=/order.jsp), which ever one is simpler for you to use.
    To load the servlet on startup, you specify the load-on-startup parameter in the web descriptor, web.xml:
    <servlet>
         <servlet-name>MappingsLoader</servlet-name>
         <servlet-class>packagename.MappingsLoader</servlet-class>
         <load-on-startup>1</load-on-startup>
    </servlet>
    where load-on-startup number is the order in which it loads the servlet, 1 being first.
    Then once you've created the hashtable, store it in servlet context.
    When you want to forward something, just use a requestdispatcher object and the hashresult to forward the request to another web component (in this case, a jsp).

  • Call View controller with some URL parameter

    Hi
    I have a 3rd party system which need to send some data to my CRM system.
    One approch which is being suggested is by sending data by URL parameter.
    I have made a new component for this and have provided the 3rd party with its URL .
    The issue with calling a view controller URL along with some specific URL parameters is that i am not able to access its parameters.when i call method GET_PAGE_URL from the DOINIT method of the controller it does not provide me with the parameter list .
    How can i access these URL parameters ?
    Regards
    Ajitabh

    HI,
    have a look at component CRM_UI_FRAME. In the page default.htm they extract URL parameters.
    You have got the REQUEST variable in your view controller as well.
    cheers Carsten

  • Complete table view controller with XML

    Hello, I'm from Brazil and am new to ios.
    Today I am making an example where I use a table view controller and fill it witharray (NSMutableArray).
    However I would do the same using XML so that now, I'm having so many difficulties to the point of not knowing where to start.
    The code I use to populate this array was.
    It is possible to use something like XML?
    #pragma mark - View lifecycle
    - (void)viewDidLoad
        [super viewDidLoad];
        // Uncomment the following line to preserve selection between presentations.
        // self.clearsSelectionOnViewWillAppear = NO;
        // Uncomment the following line to display an Edit button in the navigation bar for this view controller.
        // self.navigationItem.rightBarButtonItem = self.editButtonItem;
        registros = [NSMutableArray arrayWithObjects:@"1", @"2",@"3",@"4",@"5",@"6",@"7",@"8",@"9",@"10",@"11",@"12",@"13",@"14", nil];
    - (void)viewDidUnload
        [super viewDidUnload];
        // Release any retained subviews of the main view.
        // e.g. self.myOutlet = nil;
    - (void)viewWillAppear:(BOOL)animated
        [super viewWillAppear:animated];
    - (void)viewDidAppear:(BOOL)animated
        [super viewDidAppear:animated];
    - (void)viewWillDisappear:(BOOL)animated
        [super viewWillDisappear:animated];
    - (void)viewDidDisappear:(BOOL)animated
        [super viewDidDisappear:animated];
    - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
        // Return YES for supported orientations
        return (interfaceOrientation == UIInterfaceOrientationPortrait);
    #pragma mark - Table view data source
    - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
        // Return the number of sections.
        return 1;
    - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
        // Return the number of rows in the section.
        return [registros count];
    - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
        static NSString *CellIdentifier = @"listax";//este é o identificador da celula
        UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
        cell.textLabel.text = [registros objectAtIndex:indexPath.row];
        return cell;

    If you have a custom XML schema (not a plist), consider two approaches.
    1. Before showing your table view, use NSXMLParserto deserialize the XML document into an NSMutableArray that will be the table view data source.  Typically the array contains custom class instances; one or more class properties are used to set table cell properties in cellForRowAtIndexPath.  If you have never worked with NSXMLParser (or any other SAX parser) before, start by creating a sample app so you understand how that works.
    2. Use a 3rd-party DOM parser like GDataXML.  Load your XML document into a class property in your table view's viewDidLoad.  Then the XML document will be the table view data source since elements and attributes can be directly queried using XPath in cellForRowAtIndexPath.  If you have never worked with XML DOM and XPath before, start by creating a sample app so you understand how that works.
    If your have a lengthy complex XML document, option #1 might be more efficient because indexed array access is faster than XPath queries.  Theoretically that is why Apple's Cocoa provides DOM support on OS X but not iOS.  There are strategies to improve efficiency if necessary, including your own indexing scheme.  The best solution depends on many factors.  For example, if your XML document includes thousands of rows, but users rarely scroll past the first 10, option #1 would waste time parsing everything.
    Both of these approaches keep all data in memory, which is fast but not friendly.  Perfectly fine for reasonably sized data sets.

  • Model-View-Controller implementation help

    Hello, all. I'm updating an old, clunky, slow-as-molasses application to a slightly more responsive and expandable app with the help of the MVC pattern. However, I'm having a little trouble figuring out the best way to implement MVC in a Java app. Specifically, I'm not sure of the best way to get the model and two views talking to each other.
    My model comes in the form of a couple manager classes that provide access to all the business data for the application. This is a relatively simple client-server app where the server can request that certain data be added or deleted, and the model responds accordingly. Similarly, scheduled tasks that run every 2 minutes can cause certain data to expire or become scheduled for display.
    The model provides addXXXChangeListener methods. When a model change occurs that listeners need to know about, the model calls a notifyListeners method, and all registered listeners are notified of the change. View classes that are interested in hearing about model changes register themselves as listeners with the model and implement methods in the XXXChangeListener interface. In this way, the interaction between the model and view is almost exactly like existing interactions between event sources and listeners in Swing/AWT.
    Right now, there isn't a lot of decoupling between the model and view, since the View obviously needs a reference to the model to add itself as a listener. The controller for the app sets all that up. Is this a viable way of implementing MVC in a Java app? Any suggestions or advice would be greatly appreciated.

    Right now, there isn't a lot of decoupling between
    the model and view, since the View obviously needs a
    reference to the model to add itself as a listener.
    The controller for the app sets all that up. Is
    s this a viable way of implementing MVC in a Java
    app? Any suggestions or advice would be greatly
    appreciated.In classic MVC, the code that registers the listeners, captures the events and updates the model should be in the controller. The advantage being that you could theoretically change the view to use a different model. In reality, the view is generally (but not always) pretty specific to the model (while pieces of the model may not be) so there is little gained by doing this. The other advantage is that this can be a little cleaner and allow the controller to be 'smarter'.
    If you are simply worried about coupling the vew to a specfic implementation of the model, create interfaces for the Model classes and let the Controller supply the View with references to the implmentations.

  • How to add the model view controller in webcenter portal framework application

    i create a webcenter portal framework application.how to create a model class in my application..please help me.

    What you mean by this. You mean having model layer in webcenter portal framework application? Whats the exact requirement.? You want to create ADF BC in portal app.
    If you want to use adf taskflow application , i will recommend you to make separate adf application and use as shared lib in portal.

  • Model View Controller Deployment

    Hi,
    I have tried to deploy the ViewController layer in an OC4J instance, and the model and another instance of OC4J.
    When I tried to execute the page in the ViewController layer I receive the following message. It seems like I need something to configure in order that my databindings could access to the model layer. I have already changed the Databindings.cpx in which I point the remote Configuration of the AppModule.
    Does somebody know what is wrong or how I can solve the problem?
    500 Internal Server Error
    JBO-30003: The application pool (ec.com.carrasco.accionespersonal.model.AppModule9iAS) failed to checkout an application module due to the following exception:
    oracle.jbo.JboException: JBO-29000: Unexpected exception caught: oracle.jbo.JboException, msg=JBO-29000: Unexpected exception caught: oracle.jbo.JboException, msg=JBO-25222: Unable to create application module.
    at oracle.jbo.common.ampool.ApplicationPoolImpl.doCheckout(ApplicationPoolImpl.java:1743)
    ## Detail 0 ##
    oracle.jbo.JboException: JBO-29000: Unexpected exception caught: oracle.jbo.JboException, msg=JBO-25222: Unable to create application module.
    ## Detail 0 ##
    oracle.jbo.JboException: JBO-25222: Unable to create application module.
    at oracle.jbo.common.ampool.DefaultConnectionStrategy.createApplicationModule(DefaultConnectionStrategy.java:156)
    ## Detail 0 ##
    javax.naming.NamingException: Error instantiating web-app JNDI-context: No location specified and no suitable instance of the type 'ec.com.carrasco.accionespersonal.model.common.ejb.beanmanaged.RemoteAppModule' found for the ejb-ref ejb/AppModuleBean

    thank you for your reply,
    i did as you said but the problem persists,
    actually my Model Project contains a Session Bean , and the web browser error says that it can't find this session bean.
    this is the first time i deploy an application using jdeveloper 10g, Do you think that i have to create a Deplyment Descriptor or something like that?
    Message was edited by:
    rsader

  • How to go from a View Controller to a View Controller

    Hey everyone, I have asked this question over on Stack Overflow, and really had no luck with it.
         I am wondering how to go from one (1) View Controller that has buttons and another View Controller that has a UIWebViewer in? I know how to do the simple part to get the two to link up. But, the buttons are going to have different URL's hooked up to them, and I want to be able to reuse the Web Viewer. I am using the Swift Programming language to be able to do this.
    below is my current code that is has my buttons sitting on top of my web viewer,
    import UIKit
    import WebKit
    class ViewController: UIViewController {   
        @IBOutlet var wbView: UIWebView!
        var strUrl = ""
            @IBAction func buttonAction(sender: UIButton) {
                switch (sender.tag){
                case 1:
                    strUrl = "https://www.google.co.in/"
                case 2:
                    strUrl = "https://in.yahoo.com/"
                case 3:
                    strUrl = "https://www.facebook.com/"
                case 4:
                    strUrl = "https://bing.com/"
                default:
                    break;
                reloadWebViewWithUrl(strUrl);
            func reloadWebViewWithUrl(strUrl: NSString){
                var url = NSURL(string: strUrl);
                var request = NSURLRequest(URL: url!);
                wbView.loadRequest(request);
            override func viewDidLoad() {
                super.viewDidLoad()
                // Do any additional setup after loading the view, typically from a nib.
            override func didReceiveMemoryWarning() {
                super.didReceiveMemoryWarning()
                // Dispose of any resources that can be recreated.
    How should I go about changing this two allow my buttons to be in their own ViewController and still be able to to the secondary View Controller with the WebViewer?
    Thank You all in advanced with the help on this!

    This is the FirstViewController Code
    import UIKit
    class FirstViewController: UIViewController {
        @IBAction func webAction(sender: UIButton) {
            let index = sender.tag
            chosenURLString = addresses[index]
            performSegueWithIdentifier("WebViewSegue", sender: self)
        override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
            if let controller = segue.destinationViewController as?
                SecondViewController {
                controller.urlString = chosenURLString
                chosenURLString = nil
        private let addresses = ["", "https://www.google.com", "https://www.facebook.com", "https://spca.org", "https://www.facebook.com/wagzpack?fref=photo"]
        private var chosenURLString: String?
    This is the SecondViewController Code
    import UIKit
    class SecondViewController: UIViewController {
        @IBOutlet var webSite: UIWebView!
        var urlString: String?
        override func viewDidLoad() {
            super.viewDidLoad()
            if let urlString = urlString {
                if let url = NSURL(string: urlString) {
                    let request = NSURLRequest(URL: url)
                    webSite.loadRequest(request)
                    println("loading \(urlString)")
                else {
                    println("badly formed URL string.")
            else {
                println("missing URL string.")

  • Problem displaying modal view controller.

    I have created a view controller with view in IB, and am trying to display it as a modal view. But when I press the button all I get is a blank screen. If I look at the view object within the new view controller, I can see it has loaded the subviews, but nothing is shown. I created a test project, so I could figure out what I am doing wrong, but here is the code I have to display:
    ModalView *newView = [[ModalView alloc] initWithNibName:@"ModalView" bundle:nil];
    SubViewNewAppDelegate *delegate = [[UIApplication sharedApplication] delegate];
    [[delegate viewController] presentModalViewController:newView animated:YES];
    ModalView is a generic UIViewController created by Xcode.
    And the xib looks like:
    File's Owner (Class set to ModalView, Outlet view to View)
    First Responder (Blank)
    ViewController (Class set to ModalView, Outlet view to View)
    -View
    --Label

    Hi Maksim
              Info sent to me was very useful.
    I have performed the steps which u have sent in the link,but I didn't get the desired result.
    when I hit the "Exit" button for the first time nothing happens but when agained clicked,It gave me a error saying that "Your Application is Expired :errCode,500"
    Pl tell me wht could be the problem
    Thanks a lot
    sethu

  • Call method with an argument from another view controller

    I have a UIViewController MainViewController that brings up a modal view that is of the class AddPlayerViewController. When the user clicks 'Save' in the modal view I need to pass the Player data (which is a Player class) from the modal view to the MainViewController in addition to triggering a method in the MainViewController. What's the best way to accomplish this? I'm new to cocoa and have only tried using delegates and some ugly hacks to no avail.
    Thanks for the help.

    If I understand correctly, you have:
    1. A model object, Player.
    2. A top view controller, MainViewController.
    3. Another view controller, AddPlayerViewController, which MainViewController displays modally.
    I'm guessing that AddPlayerViewController creates a new Player object and lets the user set its values, and you need a way to get that new Player into MainViewController once they're done.
    So, here's what I'd do:
    1. Create an AddPlayerViewControllerDelegate protocol. It should declare two methods, "- (void)addPlayerViewController:(AddPlayerViewContrller*)controller didAddPlayer:(Player*)newPlayer" and "- (void)addPlayerViewControllerNotAddingPlayer:(AddPlayerViewController*)controll er".
    2. Add an attribute of type "id <AddPlayerViewControllerDelegate>" called delegate to AddPlayerViewController. Also add a property with "@property (assign)" and "@synthesize".
    3. Modify AddPlayerViewController so that if you click the "Save" button, addPlayerViewController:didAddPlayer: gets called, passing "self" and the new Player object as the two arguments. Also arrange for clicking the "Cancel" button to call addPlayerViewControllerNotAddingPlayer:.
    4. Modify MainViewController to declare that it conforms to AddPlayerViewControllerDelegate. Implement those two methods (addPlayerViewControllerNotAddingPlayer: might be an empty method if you don't want to do anything).
    5. When you create your AddPlayerViewController, set its delegate to your MainViewController.
    If you need more detail, let me know what parts you need me to elaborate on.

  • NSTimer - Model or View Controller

    Hi,
         i have a doubt on correct usage of NSTimer in a MVC pattern:
    let's suppose i'm building a chess game; a payer has 20 seconds to move one of his piece; a timer in view is present showing the time passing. If the time ends the player loose the time to move a piece.
    In this situation how to deal with NSTimer:
    I would like to put NSTimer in model since it seems to me it refers to game's logic. however doing this way my modell should know my controller in order to send recursively a message to update the "timer" (let's consider the time is a bart that becomes smaller with the time passing)
    Another solution is to put the NSTimer in view: i would then be able to update my "timeBar" and i would send recursively a message to my model asking: "is the time ended?". I do not like this solution since it seems to me the NSTimer is part of logic and i may thing the performance of the solution is not high.
    Could you please suggest me a correct approach?
    Kind Regards
    Nicolò

    You could argue that your timer is currently in a view controller, not a view. If the timer controls what the user is permitted to do in the view, it might not be appropriate to put it in the model.
    If you really want to put the timer in the model, the view controller could be a delegate of the model. The view controller would conform to the model's "timer" protocol by implementing delegate functions the model calls to notify the view controller of timer events.
    There are some scenarios where the model should contain information about the timer. For example, if a user quits the app in the middle of a turn, when the user restarts the app does he still have the remainder of the time to move? If so, the current time value (not the timer itself) should be part of the model so serializing/deserializing the model will include enough information to resume the game in the event iOS terminates the app.

  • Problem with Model View

    hi friends,
    i am working with ALE to transfer data across two clients.
    i had created two logical system EDI900, EDI950 and model view MODEL_VIEW
    but when i am distribute this model view i am getting error as
    model view MODEL_VIEW has  not been updated
    reason:maintance system in sending system EDI900
                 maintance system in receiving system EDI950
    i had searched in SDN with this keyword i got lot of links but i can't find proper solution.
    so please give me the correct solution.
    thanks in advance.
    Regards,
    Karunakar

    hi jurgen,
    thanks for your reply.
    here i am distributing model view with message type.
    and i am transferring data across two clients in one SAP system.
    here i am ligin in target system and delete the model view which previouslly assigned.
    now i am distributed successfully.
    Regards,
    karunakar

Maybe you are looking for

  • Msi Ge60 apache pro slow sometimes

    Hi, i have the ge60 now 2 month and did some reinstall because the laptop is at some point very slow. Games like call of duty are at that moment unplayeble other things like google chrome and internet are slow to. i did a clean reinstall but then it

  • Calling all Windows Server users! May TechNet Gurus announced!

    The results for May's TechNet Guru competition have been posted! http://blogs.technet.com/b/wikininjas/archive/2014/01/16/technet-guru-awards-december-2013.aspx Congratulations to all our new Gurus for May! We will be interviewing some of the winners

  • Exit code 6 - Prelude failed - CS6

    Hi I have just downloaded Production Premium CS6 today. Prelude fails with exit code 6 (see below for full error message) All other apps installed ok Can someone help or point me to where I should be asking I currently have Production premium CS5 and

  • XPATH Database Query Syntax in an Assign

    Trying to get an XPATH Database query to work by assigning the Input variable value in a simple BPEL Process to my query condition. I keep getting invalid XPATH errors. I cannot seem to figure out how get write it out. Here is what I have: <from expr

  • Using the new format. Question # 2

    When i go to my Bio > preferences there is a setting for online visibility. Is that working ? I can't see when anyone else is online. Does online visibility mean that I'm logged in to the Forum ?