Model View Control help!

Hi!
I have a var in Model called "age". From ActionPerformed in Control I want to take the value from a JTextField in View and update age. How do I do this?
ActionPerformed is triggered by a JButton..
Thx!

With MVC you should create the model, view and controller in a driver class that creates all the compoents of the MVC and merges them together. You should be passing the model as a parm to the view in the constructor.
Example Driver Class:
public MVCDriverClass {
// constructor and any other methods needed
public void initialize() {
    MyModelInterface model = new MyModel();
    MyViewInterface view = new MyView();
    MyControllerInterface controller = new MyController(mode, view);
    model.initialize();
    view.initialize();
    view.showView();
}Now in your model you need to make sure you are using the Observer pattern to notify all observers of any changes to the data model. Java already implements this for you if you want to use its utils. You simply need to extend the Observable class on your model to make it the subject and implement the Observer interface on each view you want the Subject (Observer) to notify of changes. You will see that the Observer interface has a method named update(Observer o, Object arg). You simply place any code in here that you need to update your UI values with. Let me know if you need any examples.

Similar Messages

  • Model-View-Presenter - help

    Hi,
    I recently read about Model-View-Presenter on Martin Fowler's website, and elsewhere. I think I understand the idea...
    The view just displays the GUI components..events fired from the View are delegated to a Presenter. The presenter then deals with the model and updates the View accordingly. Sound about right?
    Ok, so I learn best by example..and I haven't found any code samples yet, so I thought I'd give it a shot. Below is my code...
    Model
    * the model to be displayed in a View
    public class Album {
         private boolean isClassical;
         private String composer;
         public String getComposer() {
              return composer;
         public void setComposer(String composer) {
              this.composer = composer;
         public boolean isClassical() {
              return isClassical;
         public void setClassical(boolean isClassical) {
              this.isClassical = isClassical;
    View - interface
    import java.awt.event.ActionListener;
    * An interface which defines the methods needed by a presenter
    public interface View {
         public boolean isClassical();
         public void setClassical(boolean b);
         public boolean isComposerEnabled();
         public void setComposerEnabled(boolean b);
         public void addClassicalChangeListener(ActionListener al);
         public void showView();
    View - implementation
    import java.awt.Dimension;
    import java.awt.event.ActionListener;
    import javax.swing.JCheckBox;
    import javax.swing.JFrame;
    import javax.swing.JPanel;
    import javax.swing.JTextField;
    * A an implementation of the View interface.  It shows a checkbox
    * and a textfield.
    public class MyView extends JFrame implements View {
         private JCheckBox checkboxClassical;
         private JTextField textfieldComposer;
         private MyPresenter mp;
         public MyView() {
              checkboxClassical = new JCheckBox("Classical");
              textfieldComposer = new JTextField();
              textfieldComposer.setPreferredSize(new Dimension(100, 20));
              textfieldComposer.setEnabled(false);
              JPanel p = new JPanel();
              p.add(checkboxClassical);
              p.add(textfieldComposer);
              add(p);
              setSize(600, 400);
         public void addClassicalChangeListener(ActionListener al) {
              checkboxClassical.addActionListener(al);
         public void setPresenter(MyPresenter mp) {
              this.mp = mp;
         public void setClassical(boolean b) {
              checkboxClassical.setSelected(b);
         public boolean isClassical() {
              return checkboxClassical.isSelected();
         public void setComposerEnabled(boolean b) {
              textfieldComposer.setEnabled(b);
         public boolean isComposerEnabled() {
              return textfieldComposer.isEnabled();
         public void showView() {
              setVisible(true);
    Presenter
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    * A presenter for a View.  When the "classical" fires
    * an ActionEvent, the "composer" component is enabled or disabled.
    public class MyPresenter {
         private Album album;
         private View view;
         public MyPresenter(Album album, View viewVal) {
              this.album = album;
              this.view = viewVal;
              view.addClassicalChangeListener(new ActionListener() {
                   public void actionPerformed(ActionEvent e) {
                        view.setClassical(view.isClassical());
                        view.setComposerEnabled(view.isClassical());
              view.showView();
    }and here is a simple Main to tie it togehter.
    * Ties together the M-V-P
    public class Main {
         public static void main(String[] args) {
              Album al = new Album();
              al.setClassical(false);
              MyView myView = new MyView();
              MyPresenter mp = new MyPresenter(al, myView);
              myView.setPresenter(mp);
    }Ok, the idea is this. The GUI shows a checkbox and a textfield. basically, if the checkbox is selected the textfield is enabled and can be typed into. If the checkbox is not selected, the textfield is disabled. From the model point of view, if isClassical is false, then no composer can be defined.
    So, is my code following the pattern? Does anyone have any simple code to contribute as an example? For some reason is just seems weird to me that I would have an interface define a bunch of methods that the Presenter can call. And I have to create the Model and View which get passed to the presenter, and then I have to set the presenter on the view....it just seems weird to me.
    Any comments, suggestions, examples??
    Thanks for your time and contributions.

    The other information didnt answer my questions. The response was mixing the idea of MVC instead of MVP, and then the response discussed what they thought was wrong with MVP and why they use a different model. I am looking for help on understanding the pattern more, also for someoen (who knows about MVP) to look at my sample code and help me understand what I did right/wrong.
    Thanks.

  • Model View Control

    Hi.. i need some help when designing the view part of my application. My main problem is that sometimes i do not know how to separate the control code from the one needed in the view part.For example, if I have some componentes(implementes mouse motion listener) that can be moved., that code where should it goes?

    My 2 Shekels' worth (for what it's worth):
    1) Perhaps a component should not implement a Listener.
    2) Rather the component could be part of the View
    3) And the Listener could be part of the Control.
    4) The Model holds the position of the movable component.
    5) The MouseListeners of the Control tell the Model when a move occurs.
    6) The Model notifies the View that a change has occurred (Observer Pattern)
    7) The View queries the Model's state and changes itself accordingly.

  • Model view control & JProgressBar

    hello,
    I didn't understand to handle with the Progressbar.
    For example when want to represent the download of a file:
    I have a class TransferE (Entity), which does the transfer of the file
    I have a class TransferUI (User Interface) for the user interface
    I have a class TransferC (Control) between ui and entity
    now how to update the progressbar?
    The download need to run in an own Thread i think.
    Do I have to run an extra Thread in the UI to get the status in a specified interval?
    Or can I give the ProgressBar to the Entityclass as parameter, so that the bar will be updated in the entity's run()-method?
    cheers
    Tobias

    Hi, I had a similar question/problem. its not that i don't know how to use a progress bar (or maybe i don't), its more an issue of design. if we pass the progress bar to an entity or control class then we are mixing interface code with entity or control code. after all these two do not need to know the progress of their methods. its seems that which ever way it is done when we use progress bars, this problem arises. i wonder if there is a way to find out whether a method has completed or not just by its execution

  • Help needed to load a viewer control in Access

    Hi,
    I'm having a problem viewing a Crystal Report in Access.  The code looks like this:
    Dim crApp As New CRAXDRT.Application
    Dim crRep As CRAXDRT.Report
      'load a standalone report created in the designer
        Set crRep = crApp.OpenReport("c:\fax\database\reports\PO.rpt")
      CRViewer91.ReportSource = crRep
      ' print preview
      CRViewer91.ViewReport
    I'm loading CRADXDRT from CRADXDRT9.DLL.  The report viewer control is called "Crystal Report Viewer Control 9, which i believe is coming from CRVIEWER9.DLL.
    When I step through my code, CRADCDRT seems to load fine, however when I execute the CRViewer91.ViewReport step, the program seems to execute the code, but doesn't display any report.
    My question is:  am I using the correct control?  I have CR9 and 11 on my system.  I also have VB, which I believe also has a version of CR.  I'm trying to use 9, which is what the report was written in. 
    Thanks for your help.

    No it is not. The crviewer was part of the RDC which is now retired. The last version to ship the RDC was 11.5.
    See the [statement of direction|https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/80bd35e5-c71d-2b10-4593-d09907d95289] for more details.
    Ludek

  • HELP: How to implement Model Predictive Control in LabVIEW?

    Hi, everyone
    I have a problem on realizing model predictive control algorithm in LabVIEW 7.1.1.
    What I have now is a linear model predictive control algorithm designed with Matlab -- Model Predictive Control Toolbox. Under simulation in SIMULINK, it works well.
    Now I need to implement this algorithm with hardwares such as sensors and actuaors by LabVIEW.  Initially, I try to use the NI Simulation Interface Toolkit (SIT) 2.0 connect the simulink module with my LabVIEW interface to get the model calculation out of matlab, then send them into LabVIEW. It failed, because SIT can only help me design a simulation interface in LabVIEW based on Matlab model. Not the parrallel working mode I need. I am wondering,  does any  people here have experience dealing with the similar problems? 
    Thanks! Appreciate your time and help!

    Thanks Jarrod.
    With your suggestion, I tried LabVIEW simulation module. It seems the Model Predictive Control (MPC) block I developed in Matlab/SIMULINK cannot be supported by LabVIEW simulation translator. 
    The parrallel mode means I want to use the input from DAQ card as the input for MPC block (Basically, it is just a control algorithm with I/O), and I would like to use the output from MPC block as my actuator output to external device. However, when I use Simulation Interface Toolkit to import my MPC block from Matlab to LabVIEW. It is completely sealed. I mean I cannot pull the I/O ports out from this block in LabVIEW. That is the problem where I am now.
    BTW: I found there is optimization function in Simulation module of LabVIEW.  But Why I cannot find that function in my Simulation module (LabVIEW 7.1.1 + Simulation Module 1.0) ?
    Do I need to upgrade my LabVIEW to 8.0, since I heard about several powerful math functions there. And I am hoping with these math tools, I could realize MPC by myself in LabVIEW.
    Anyway, Thanks a lot for your help!!!

  • Help Needed regarding to Table View Control

    Hi Abapers
    In Table View Control which property or system variable keeps the user selected row's row id.
    Situation is that user enters many records into sales details table view. Table view contains the fields, productid product no qty discount and rate. Suppose user wants to delete one particular record(sales details) from that table view while entering this sales details .here i want to know which is that particular row that the user selected. Table views which property keeps this row no information. i am very glad if you people give me more information abount table View Controls .
    With regards
    Anoop.

    Hello Anoop,
    post your questions in the correct forums and you can hope to get a better answer. This forum as you see is the suggestions and comments forum and not the ABAP forum.
    Sameer

  • Help Needed on Table View Control

    Hi Abapers
    In Table View Control which property or system variable keeps the user selected row's row id.
    Situation is that user enters many records into sales details table view. Table view contains the fields, productid product no qty discount and rate. Suppose user wants to delete one particular record(sales details) from that table view while entering this sales details .here i want to know which is that particular row that the user selected. Table views which property keeps this row no information. i am very glad if you people give me more information abount table View Controls .
    With regards
    Anoop.

    You would have to use the outbound plugs to transfer data from your component to the other component. Here you have a parameter IV_DATA_COLLECTION. Fill the entries you want to fill here.
    Check the Sold to Party pop up while creating Quotation for Sales cycle when you log in with SALESPRO.
    Regards
    Kavindra
    Edited by: joshi_kavindra on Nov 23, 2011 5:03 PM

  • Problem in crystal report viewer control's toolbar "export"button using SSL

    Hi,
    I would like to ask. My project is using BO XI Release 2 and VS-Studio 2005. Initially my project doesn't use SSL... At that time when i view the report with crystal report viewer control and can export (using built-in toolbar "export button"). Now project is using SSL and canu2019t export the error is
    u201CInternet Explorer cannot download file from server.
    Internet Explorer was not able to open this Internet site. The requested site is either unavailable or cannot be found. Please try again later.u201D
    Actually this error can solve "Cache-control" change to "no-cache". But I donu2019t know in crystal reportu2026
    Anyone can help ???
    Thanks

    In Internet Explorer, go to Tools -> Internet Options -> Advanced and ensure "Do not save encrypted pages to disk" is unchecked.
    Default is to have that option checked. 
    It was considered a IE security issue that IE saves all content to temp disk location unencrypted, even those pages served by HTTPS (for example, let's say you use HTTPS to download your bank info, and it's stored to temp disk for someone else to retrieve later).  So more recent versions of IE implemented that option setting.
    How that option setting works is strange - it downloads the file, saves to disk, then deletes the copy from the disk immediately, before passing it to the application responsible for the MIME type.  So the application tries to open a directory path to a non-existing file.
    Issue is specific to IE, and it's not something you can control via the SDK.
    Sincerely,
    Ted Ueda

  • Crystal Report Viewer Control error

    Please Help, I have a web application developed in .net 2005 which is using crystal reports developer product version 10.0.0.533.
    This web application with crystal is working fine on my local machine with OS windows xp, but on the windows server 2003 the application web form is running into "couldnot load file or assembly 'CrystalDecision.VSDesigner, Version=10.0.0.3300' or one of its dependencies"
    I have compared the assembly information of my local machine with that of the server and could not see the crystaldecision.vsdesigner version 10.0.0.3300 on the server 2003. I have uninstalled microsoft .net 2005 and crystal reports and installed crystal first and visual studio .net 2005 next and vice versa but still could not see that particular assembly available in the windows 2003 server.
    Please suggest as what to do for the assembly to be available on the server so crystal report viewer control can be created with out error. Thanks for any help.

    Hello Sunitha,
    Visual Studios 2005 ships with a bundled edition of Crystal Reports.  This bundled edition is based on the v10 code stream, but it is not CR10.  It's CR.NET for Visual Studios and it's v10.2. Crystal Reports 10.0 and the bundled CR.NET 10.2 for VS2005 are not interchangeable.
    The stand alone version of Crystal Reports 10 is not expected to integrate correctly into VS2005.  If you have CR10 Developer installed on your VS2005 machine you can force VS2005 to use the CR10.0 assemblies, but it is not supported.
    You need to clean up your application so that it's referencing the 10.2 version assemblies and then deploy the 10.2 runtime files.  You can visit the [Crystal Reports for Visual Studio .NET Runtime Distribution - Versions 9.1 to 12.0|https://www.sdn.sap.com/irj/scn/wiki?path=/display/bobj/crystalReportsruntimeforVisualStudio.NET] Wiki for a nice overview of the various versions of Crystal Reports, as well as a listing of the runtime files to match the version of Crystal Reports that is being used.  For VS2005 and bundled CR.NET look at the "CR 10.2 (VS .NET 2005)" section of the Wiki.
    Sincerely,
    Dan Kelleher

  • Unable to Distribute Model View in BD64

    Hi Gurus,
    Model View - SR2CLNT251
    Receiver of Model View - EA1CLNT251
    i went to txcode bd64 > i clicked on model view SR2CLNT251 then went to edit > model view > distribute and clicking the logical system of EA1CLNT251. then error will be encountered.
    Model view SR2CLNT251 has not been updated
    Reason: No authorization to change model view SR2CLNT251
    .....authorization object B_ALE_MODL
    .....Parameter: activity 02, model view SR2CLNT251
    i already given correct authorization to my ID, but still the error persists.
    Please help. Thanks!
    Regards,
    Tony

    Hi Tony,
    You need  authorization for authorization object  'B_ALE_MODL'  in system I guess either in system SR2CLNT251  or in EA1CLNT251.
    Best Regards,
    Tushar

  • Mapping Variables(Object View) to Measures(Model View)

    Hi,
    In my AW, I have created a cube, And then I have created a new variable in the object view and populated it using load programs. Now. when I try to create a measure in the model view of the same cube based on this variable, I cannot see any option for assigning a variable to a measure. Can someone please help me out in doing this?
    I need the measure in the model view, because it looks like, when I create a relational view, only the measures that are defined in the model are added to the view and not the variables available in the object model.
    Thanks,
    Bharat

    Hi Bharat,
    The mapping editor is used to map a measure to a relational data source. Therefore, unless you convert your data source used by your DML program to a relational table/view (if it is a text file you can use an external table to present the data to AWM as a relational table, or if it is an Excel spreadsheet and your database is on Windows you can use the heterogenous gateway service to load directly from Excel by exposing the Excel worksheet as a relational table) you will not be able to use the mapping editor.
    To assign an OLAP variable to an measure within a cube you will need to create a custom calculated measure. This will allow you to create a measure that "maps" to your OLAP DML program. There is an Excel utility on the OLAP OTN home page that allows you to create custom calculated measures (at the moment this feature is not AWM10gR2 - but is available within AWM 11g). Click here for more information:
    http://download.oracle.com/otn/java/olap/SpreadsheetCalcs_10203.zip
    My advice would be to try and convert your data source to a relational table/view and using the mapping editor. This will allow you to benefit from the many new features within OLAP cube storage such as compressed composites, data compression, paralled processing, partitioning and aggregation maps. Of course you can code all this manually but it is much easier to let AWM do all this for you via a few mouse clicks. Please note - that everything you build outside of the AWM model view has to be managed (defined, updated, backed up etc) by you rather AWM. So while there are lots of advantages of using OLAP DML, I personally always try to load data into my OLAP cubes using AWM mappings and save OLAP DML for providing the advanced types of analysis that make OLAP such an excellent calculation engine.
    Hope this helps
    Keith Laker
    Oracle Data Warehouse Product Management
    OLAP Blog: http://oracleOLAP.blogspot.com/
    OLAP Wiki: http://wiki.oracle.com/page/Oracle+OLAP+Option
    DM Blog: http://oracledmt.blogspot.com/
    OWB Blog : http://blogs.oracle.com/warehousebuilder/
    OWB Wiki : http://wiki.oracle.com/page/Oracle+Warehouse+Builder
    DW on OTN : http://www.oracle.com/technology/products/bi/db/11g/index.html

  • Java Script Error while deploying a Model with Value Help

    Hi,
    I am using EP 7.0 SP 10.
    I am trying to deploy a model which includes the Value Help for an Input field, and i am trying to deploy this model.
    The model compiles successfully, but gives a Java Script Error while deploying the model,
    ! Error on Page
    When Click on this java script error, it shows that ,
    Line:14985
    Char 1: Error
    object does n't support this property or method.
    code
    URL: <serverhost>/VCRes/WebContent/VisualComposer6.0/bin/223334.htm?24102006.1712.
    The Same model works in dev server, and it fails in the production server.
    Thanks and Regards,
    Sekar

    Hi jakob,
    Thankyou for your quick response.
    I did a basic model with the help of a documentation which i got from this forums.I created a iView and from there i used Bapi "BAPI_SALESORDER ".
    I created a Input Form and a outpot form (table view).I tested model and am able to get the output.but when i try to deploy it is giving me the error.
    And i think am not paring any formulas here.
    Please guide me.
    thanks and regrads
    Pradeep.B

  • Report Viewer control in sharepoint 2013 provider hosted app

    sharepointSite/_vti_bin/ReportServer
    We are migrating sp 2010 site to SP 2013 provider hosted app. we are using Report viewer control (version 10.0.0) in .net application app server, And the reporting service is configured in sharepoint site and report is uploaded in the document
    library. We are using claims based authentication
    ReportViewer1.ServerReport.ReportServerUrl =
    newUri("sharepointSite/_vti_bin/ReportServer");
    ReportViewer1.ServerReport.ReportPath = @"sharepointSite/_vti_bin/ReportServer?sharepointSite/Reports/Report1.rdl";
    and am getting an error
    ReportServerException: For more information about this error navigate to the report server on the local server machine, or enable remote errors]
    [ReportServerException: The user does not exist or is not unique.]
    [ReportServerException: Report Server has encountered a SharePoint error. (rsSharePointError)]
       Microsoft.Reporting.WebForms.ServerReportSoapProxy.OnSoapException(SoapException e) +82
       Microsoft.Reporting.WebForms.Internal.Soap.ReportingServices2005.Execution.ProxyMethodInvocation.Execute(RSExecutionConnection connection, ProxyMethod`1 initialMethod,
    ProxyMethod`1 retryMethod) +770
       Microsoft.Reporting.WebForms.ServerReport.EnsureExecutionSession() +105
       Microsoft.Reporting.WebForms.ServerReport.SetParameters(IEnumerable`1 parameters) +163
       BP.SDC.eXPP.UIAppsWeb.UserControls.Baseline.ProgressDashboard.RefreshDashboardReport(Int32 userRoadMapDisciplineId, String roadmapSection)
    System.Web.UI.Page.ProcessRequestMain(Boolean
    includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3804
    Can you please help me to solve this issue

    Hi,
    According to your post, my understanding is that you had issues about the provider hosted app.
    Per the error, the issue may be related to the permission issue.
    For a better troubleshooting, we can check with the following steps.
    To norrow down the issue, please create a new and clean app to test whether it has the same issue.
    You can check the ULS log to see if anything unexpected occurred when you deploy the app and open the site page.
    For SharePoint 2013, by default, ULS log is at
    C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\15\LOGS
    You can check the ULS log by the methods here:
    http://blogs.msdn.com/b/opal/archive/2009/12/22/uls-viewer-for-sharepoint-2010-troubleshooting.aspx
    http://msdn.microsoft.com/en-us/library/gg193966(v=office.14).aspx
    Thanks,
    Jason
    Forum Support
    Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Subscriber Support, contact
    [email protected]
    Jason Guo
    TechNet Community Support

  • SSRS reports are not fitting properly in Report Viewer Control

    Hi All,
    We are using Report Viewer Control to render SSRS reports & show it on SharePoint web page. In .aspx page we are putting Report Viewer Control as follows:
    The zoom percent of Report we are getting from Report Server is 100%. We are making it as 50% to show it on our page. On one page, we are showing 2 reports.
    <rsweb:ReportViewer ID="rpv2Chart1" runat="server" Font-Names="Verdana" Font-Size="8pt" ProcessingMode="Remote" Height="211px" Width="813px" ZoomPercent="50"></rsweb:ReportViewer >
    The reports are coming. But the reports which we are getting inside the control are not readable & 25% of Report Viewer Control on our right hand side is blank.
    As you can see it's not readable. For readability we want to use that white space also & want to utilize full controls's space. But if we try to increase percentage from our report viewer tag, then the graph is zooming in with both, height & width
    so it's going out of control.
    Client don't want scroll bars on Report Viewer control. We just want to utilize the entire Report Viewer Control space.
    Can anyone suggest us how to do that?
    Thanks,
    Sanjay

    Hi Sanjay,
    I'm afraid that it is not the correct forum for this issue.
    If it is the SSRS issue, you could post this issue here:
    http://social.technet.microsoft.com/Forums/sqlserver/en-US/home?forum=sqlreportingservices
    If it is the VS report control issue, maybe you would get better response here:
    http://social.msdn.microsoft.com/Forums/en-US/home?forum=vsreportcontrols
    Best Regards,
    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.

Maybe you are looking for

  • How do I fix a project that won't open?

    I have a few Final Cut Pro X projects that won't appear in the Project Library. Here's a link to the file, could someone try opening it on there system to see if it works for them? https://www.dropbox.com/s/nswzlfw285ys936/CurrentVersion.fcpproject I

  • Display Message in WD Application

    Hello Everyone, I am a bit new to WD ABAP. So, please bare with me if I am asking very fundamental questions. My requirement is as follows:- After executing a BAPI in WD Application, I want to show the return messages of the BAPI in very nice manner.

  • How can i find out the resolution and accuracy of PXI-6602 module?

    I have a 32 bit  8 channel PXI-6602 counter module.  PXI card is interfaced to PC with MXI-4 link. How can i find out the resolution and accuracy of this system.What is the maximum accuracy and resolution i will get from this system. Because optical

  • IMP Version incompatibility between 10.2.0.4 and 10.1.0.5.0?

    Dear all, I am trying to run to do an import from oracle 10.2.0.4 to 10.1.0.5.0 So on the source server, I did an exp of the db And on the destination server, I am doing an IMP I am having the below error: IMP-00008: unrecognized statement in the exp

  • How to set up email notifier in xp and mypostoffice.co.uk mail server

    I have tried to input info into settings box indifferent forms but still fails test