Splitting GUI from Code

Hi, I created a Tetris game and I didn't split GUI from code.
but since I'm trying to learn from this I would like to split it.
so I created 3 JPanels a controller and a JFrame in different classes.
I think this is the best solution?
now I have for example this piece of code in my Canvas TetrisBoard .paint method
wich draws a TetrisBoard on the screen.
  public void paint(Graphics2D g) {
    Color color;
    for(int row = 0 ; row < rows ; row++)
      for(int col = 0 ; col < cols ; col++) {
        /* Get The Color for the current Position */
        switch(board[ row ][ col ]) {
          case Block.T_Block: color = Block.T_COLOR; break;
          case Block.I_Block: color = Block.I_COLOR; break;
          case Block.J_Block: color = Block.J_COLOR; break;
          case Block.L_Block: color = Block.L_COLOR; break;
          case Block.O_Block: color = Block.O_COLOR; break;
          case Block.S_Block: color = Block.S_COLOR; break;
          case Block.Z_Block: color = Block.Z_COLOR; break;
          default:color = Color.GRAY;
        g.setColor(color);
        /* Fill & Draw the rectangle with the given color from above. */
        g.fillRect(col*Block.TILE_SIZE, row*Block.TILE_SIZE, Block.TILE_SIZE,Block.TILE_SIZE);
        g.setColor(g.getColor().darker());
        g.drawRect(col*Block.TILE_SIZE, row*Block.TILE_SIZE, Block.TILE_SIZE,Block.TILE_SIZE);
}How do I transfer this to my JPanel, controller class?
The JPanel classes should they know about the board, or should they only containt the g.drawRect method. or something like this drawBoard(color, board, tile_size)
so in general should the JPanel, controller classes contain any code not related to drawing. (KeyListeners, looping arrays...)
Message was edited by:
stef569

You might want to have a look at implementations of the Model-view-controller (MVC) pattern as this may be a decent way to separate things out. Some reference sources include:
http://en.wikipedia.org/wiki/Model-view-controller
http://www.cs.cmu.edu/~pattis/15-1XX/15-200/lectures/modelinmvc/index.html
http://www.stanford.edu/class/cs106a/handouts/43-mvc-example.pdf
Also, I'm not sure about how to answer your specific question without looking at your code. It'd be great if you could post it, but this may not be feasible if it is large.

Similar Messages

  • Selecting in Table  from code

    hello,
    I have a question, you know if you show a list or a table on te screen , you can select an item by clicking on it, you actualy see what you selected because it turns blue (background). What i would like to do is the same but from my code, i select something from code , and the user can see it because it turns bleu
    Greetz
    dsnico

    Hi,
    I'm not sure, but it looks like you can set the selection model of the JTable to be a ListSelectionModel which supports a setSelectionInterval(int index0, int index1) interface. Setting the interval may select those rows/cells in the gui.
    Daniel Roth

  • [svn:fx-4.0.0] 13595: split airframework from airspark docs

    Revision: 13595
    Revision: 13595
    Author:   [email protected]
    Date:     2010-01-18 15:24:33 -0800 (Mon, 18 Jan 2010)
    Log Message:
    split airframework from airspark docs
    -delete airframework/bundles/[locale]/docs/spark xml's
    -add airspark/bundles/[locale]/docs/spark xml's
    -added airspark/bundles/en_US/ english properties
    -modified airspark/build to:
      -use en_US properties for each of the locales until localized
      -use the localized spark doc files for each locale in the fat-swc target
    QE notes:
    Doc notes: code hinting should be localized for airspark
    Bugs: http://bugs.adobe.com/jira/browse/SDK-25065
    Reviewer: gaurav 
    Tests run: full build,checkintests,doc,other.locales
    Is noteworthy for integration: no
    Ticket Links:
        http://bugs.adobe.com/jira/browse/SDK-25065
    Modified Paths:
        flex/sdk/branches/4.0.0/frameworks/projects/airspark/build.xml
    Added Paths:
        flex/sdk/branches/4.0.0/frameworks/projects/airspark/bundles/
        flex/sdk/branches/4.0.0/frameworks/projects/airspark/bundles/de_DE/
        flex/sdk/branches/4.0.0/frameworks/projects/airspark/bundles/de_DE/docs/
        flex/sdk/branches/4.0.0/frameworks/projects/airspark/bundles/de_DE/docs/spark.accessibili ty.xml
        flex/sdk/branches/4.0.0/frameworks/projects/airspark/bundles/de_DE/docs/spark.components. windowClasses.xml
        flex/sdk/branches/4.0.0/frameworks/projects/airspark/bundles/de_DE/docs/spark.components. xml
        flex/sdk/branches/4.0.0/frameworks/projects/airspark/bundles/de_DE/docs/spark.skins.spark .windowChrome.xml
        flex/sdk/branches/4.0.0/frameworks/projects/airspark/bundles/de_DE/docs/spark.skins.spark .xml
        flex/sdk/branches/4.0.0/frameworks/projects/airspark/bundles/en_US/
        flex/sdk/branches/4.0.0/frameworks/projects/airspark/bundles/en_US/SharedResources.proper ties
        flex/sdk/branches/4.0.0/frameworks/projects/airspark/bundles/en_US/collections.properties
        flex/sdk/branches/4.0.0/frameworks/projects/airspark/bundles/en_US/containers.properties
        flex/sdk/branches/4.0.0/frameworks/projects/airspark/bundles/en_US/controls.properties
        flex/sdk/branches/4.0.0/frameworks/projects/airspark/bundles/en_US/core.properties
        flex/sdk/branches/4.0.0/frameworks/projects/airspark/bundles/en_US/effects.properties
        flex/sdk/branches/4.0.0/frameworks/projects/airspark/bundles/en_US/formatters.properties
        flex/sdk/branches/4.0.0/frameworks/projects/airspark/bundles/en_US/skins.properties
        flex/sdk/branches/4.0.0/frameworks/projects/airspark/bundles/en_US/styles.properties
        flex/sdk/branches/4.0.0/frameworks/projects/airspark/bundles/fr_FR/
        flex/sdk/branches/4.0.0/frameworks/projects/airspark/bundles/fr_FR/docs/
        flex/sdk/branches/4.0.0/frameworks/projects/airspark/bundles/fr_FR/docs/spark.accessibili ty.xml
        flex/sdk/branches/4.0.0/frameworks/projects/airspark/bundles/fr_FR/docs/spark.components. windowClasses.xml
        flex/sdk/branches/4.0.0/frameworks/projects/airspark/bundles/fr_FR/docs/spark.components. xml
        flex/sdk/branches/4.0.0/frameworks/projects/airspark/bundles/fr_FR/docs/spark.skins.spark .windowChrome.xml
        flex/sdk/branches/4.0.0/frameworks/projects/airspark/bundles/fr_FR/docs/spark.skins.spark .xml
        flex/sdk/branches/4.0.0/frameworks/projects/airspark/bundles/ja_JP/
        flex/sdk/branches/4.0.0/frameworks/projects/airspark/bundles/ja_JP/docs/
        flex/sdk/branches/4.0.0/frameworks/projects/airspark/bundles/ja_JP/docs/spark.accessibili ty.xml
        flex/sdk/branches/4.0.0/frameworks/projects/airspark/bundles/ja_JP/docs/spark.components. windowClasses.xml
        flex/sdk/branches/4.0.0/frameworks/projects/airspark/bundles/ja_JP/docs/spark.components. xml
        flex/sdk/branches/4.0.0/frameworks/projects/airspark/bundles/ja_JP/docs/spark.skins.spark .windowChrome.xml
        flex/sdk/branches/4.0.0/frameworks/projects/airspark/bundles/ja_JP/docs/spark.skins.spark .xml
        flex/sdk/branches/4.0.0/frameworks/projects/airspark/bundles/ru_RU/
        flex/sdk/branches/4.0.0/frameworks/projects/airspark/bundles/ru_RU/docs/
        flex/sdk/branches/4.0.0/frameworks/projects/airspark/bundles/ru_RU/docs/spark.accessibili ty.xml
        flex/sdk/branches/4.0.0/frameworks/projects/airspark/bundles/ru_RU/docs/spark.components. windowClasses.xml
        flex/sdk/branches/4.0.0/frameworks/projects/airspark/bundles/ru_RU/docs/spark.components. xml
        flex/sdk/branches/4.0.0/frameworks/projects/airspark/bundles/ru_RU/docs/spark.skins.spark .windowChrome.xml
        flex/sdk/branches/4.0.0/frameworks/projects/airspark/bundles/ru_RU/docs/spark.skins.spark .xml
        flex/sdk/branches/4.0.0/frameworks/projects/airspark/bundles/zh_CN/
        flex/sdk/branches/4.0.0/frameworks/projects/airspark/bundles/zh_CN/docs/
        flex/sdk/branches/4.0.0/frameworks/projects/airspark/bundles/zh_CN/docs/spark.accessibili ty.xml
        flex/sdk/branches/4.0.0/frameworks/projects/airspark/bundles/zh_CN/docs/spark.components. windowClasses.xml
        flex/sdk/branches/4.0.0/frameworks/projects/airspark/bundles/zh_CN/docs/spark.components. xml
        flex/sdk/branches/4.0.0/frameworks/projects/airspark/bundles/zh_CN/docs/spark.skins.spark .windowChrome.xml
        flex/sdk/branches/4.0.0/frameworks/projects/airspark/bundles/zh_CN/docs/spark.skins.spark .xml
    Removed Paths:
        flex/sdk/branches/4.0.0/frameworks/projects/airframework/bundles/de_DE/docs/spark.accessi bility.xml
        flex/sdk/branches/4.0.0/frameworks/projects/airframework/bundles/de_DE/docs/spark.compone nts.windowClasses.xml
        flex/sdk/branches/4.0.0/frameworks/projects/airframework/bundles/de_DE/docs/spark.compone nts.xml
        flex/sdk/branches/4.0.0/frameworks/projects/airframework/bundles/de_DE/docs/spark.skins.s park.windowChrome.xml
        flex/sdk/branches/4.0.0/frameworks/projects/airframework/bundles/de_DE/docs/spark.skins.s park.xml
        flex/sdk/branches/4.0.0/frameworks/projects/airframework/bundles/fr_FR/docs/spark.accessi bility.xml
        flex/sdk/branches/4.0.0/frameworks/projects/airframework/bundles/fr_FR/docs/spark.compone nts.windowClasses.xml
        flex/sdk/branches/4.0.0/frameworks/projects/airframework/bundles/fr_FR/docs/spark.compone nts.xml
        flex/sdk/branches/4.0.0/frameworks/projects/airframework/bundles/fr_FR/docs/spark.skins.s park.windowChrome.xml
        flex/sdk/branches/4.0.0/frameworks/projects/airframework/bundles/fr_FR/docs/spark.skins.s park.xml
        flex/sdk/branches/4.0.0/frameworks/projects/airframework/bundles/ja_JP/docs/spark.accessi bility.xml
        flex/sdk/branches/4.0.0/frameworks/projects/airframework/bundles/ja_JP/docs/spark.compone nts.windowClasses.xml
        flex/sdk/branches/4.0.0/frameworks/projects/airframework/bundles/ja_JP/docs/spark.compone nts.xml
        flex/sdk/branches/4.0.0/frameworks/projects/airframework/bundles/ja_JP/docs/spark.skins.s park.windowChrome.xml
        flex/sdk/branches/4.0.0/frameworks/projects/airframework/bundles/ja_JP/docs/spark.skins.s park.xml
        flex/sdk/branches/4.0.0/frameworks/projects/airframework/bundles/ru_RU/docs/spark.accessi bility.xml
        flex/sdk/branches/4.0.0/frameworks/projects/airframework/bundles/ru_RU/docs/spark.compone nts.windowClasses.xml
        flex/sdk/branches/4.0.0/frameworks/projects/airframework/bundles/ru_RU/docs/spark.compone nts.xml
        flex/sdk/branches/4.0.0/frameworks/projects/airframework/bundles/ru_RU/docs/spark.skins.s park.windowChrome.xml
        flex/sdk/branches/4.0.0/frameworks/projects/airframework/bundles/ru_RU/docs/spark.skins.s park.xml
        flex/sdk/branches/4.0.0/frameworks/projects/airframework/bundles/zh_CN/docs/spark.accessi bility.xml
        flex/sdk/branches/4.0.0/frameworks/projects/airframework/bundles/zh_CN/docs/spark.compone nts.windowClasses.xml
        flex/sdk/branches/4.0.0/frameworks/projects/airframework/bundles/zh_CN/docs/spark.compone nts.xml
        flex/sdk/branches/4.0.0/frameworks/projects/airframework/bundles/zh_CN/docs/spark.skins.s park.windowChrome.xml
        flex/sdk/branches/4.0.0/frameworks/projects/airframework/bundles/zh_CN/docs/spark.skins.s park.xml

    I had downloaded it for test, and requested for evaluation license...
    But I haven't got license, and also I am not able to find Flash Builder Plugins from HFCD site....
    I think those plugins are removed from site....
    Please help me, if anyone have those plugins...

  • How to control iTV GUI from server

    I wanna develop iTV like DVB-MHP Ref-Impl at devicetop.com, but I want to control the GUI from server not build the GUI at client. it's like if we build web page database. at client side will request page to server and server send the UI+database to client. but the client side is iTV from devicetop. can I realize this???
    what web server that can make it realize??

    Well, MHP doesn't explicitly support it, but if you can implement it, then it's allowed. Implementing it is the hard part :)
    The rest of this answer assumes that you're not using DVB-HTML (fairly safe, since no available platform that I know of currently supports it). If this isn';t the case, please ignore the rest of this.
    Narakrishna, why do you want to build the GUI on the server and not the client? Given the way that MHP is designed to operate (e.g. like writing any other Java code, where the client running the app handles everything), then doing this will get extremely complex. You're assuming that a return channel exists and is always on, which will not be the case for most users. Since most of the existing MHP implementations use PSTN modems for the return channel if they have one, using an application like this could get very expensive for the user. This situation isn't likely to change in the short term.
    It could also be more computationally expensive to render a GUI built on the server than to just build the GUI on the client, since the GUI would eventually have to be converted to Java objects to be displayed. It's much easier to simply build the GUI on the client from Java objects int he first place.
    One way of doing someting similar (at the expense of object carousel size and application loading time) would be to hold the descriptions of pre-built GUI components in the oject carousel. You can then update these when you need to. There's a couple of downsides to this approach though:
    1) the GUI components are the same for every user
    2) depending on what you wanted, you'd still need to do some customisation on the client.
    3) you need some way of turning the description in to a real Java GUI component. Maybe you could serialise Java objects for your GUI and do it that way, but I'm not sure.
    On the whole, I don't think that this is the best approach to building a GUI for MHP apps due to the limitations of the platform.

  • How to disable GUI from dispalying from CentOS to X server (XManager 3)

    i have a RAC system installed and normally login to both boxes remotely using my laptop, at some point i wanted to install the listener using a GUI so i decided to use XManager3 but had problems connecting, so i decided to install the listener on the box itself but now i have a problem because when a run the netca command i get an error
    Error:#
    xlib: connection to "0.0" refused by server
    Xlib: No protocol specified
    java.lang.NullPointerException
    at oracle.ewt.lwAWt.BufferedApplet.<init>(Unknown Source)
    at oracle.net.ca.NetCA.<init>(Unknown Source)
    at oracle.net.ca.NetCA.<init>(Unknown Source)
    Oracle Net Services configuration failed. The exit code is -1
    how can i disable X server on my host, because the problem is, when i run the netca command on my host (linux1) it is looking to display it on the X server whereas i just want it to display the GUI from the host console

    oh my, another X question.
    setup an X server on your local machine (like Xming) or use MAC or linux, and use ssh -X to tunnel X.
    the ssh daemon will arrange the DISPLAY, no manual intervention is needed after logging in using ssh -X.

  • Sharepoint designer 2013 workflow kickoff issue from code

    Problem Statement: Start a  SharePoint 2013 designer Reusable Workflow with STS Authenticated User. We are trying to start to SharePoint 2013 designer Reusable Workflow with
    STS authenticated user using code but when we do that, we get following error. RequestorId: a3ce6dc6-31ec-23f3-0000-000000000000. Details: RequestorId: a3ce6dc6-31ec-23f3-0000-000000000000. Details: An unhandled exception occurred during the
    execution of the workflow instance. Exception details: System.ApplicationException: HTTP 401 {"error_description":"The server was unable to process the request due to an internal error. For more information about the error, either turn on IncludeExceptionDetailInFaults
    (either from ServiceBehaviorAttribute or from the <serviceDebug> configuration behavior) on the server in order to send the exception information back to the client, or turn on tracing as per the Microsoft .NET Framework SDK documentation and inspect
    the server trace logs."} {"x-ms-diagnostics":["3001000;reason=\"There has been an error authenticating the request.\";category=\"invalid_client\""],"SPRequestGuid":["a3ce6dc6-31ec-23f3-b3ab-aef56fc7e299"],"request-id":["a3ce6dc6-31ec-23f3-b3ab-aef56fc7e299"],"X-FRAME-OPTIONS":["SAMEORIGIN"],"SPRequestDuration":["65"],"SPIisLatency":["0"],"Server":["Microsoft-IIS\/8.0"],"WWW-Authenticate":["Bearer
    realm=\"de9da885-f7bf-4564-a3a5-
    Alternate approach we are following : We have created a windows authenticated user and gave him all the necessary permission to trigger the workflow(contribute, full control). Then we are creating the User token
    for that user and opening the site with the help of the generated user token. By this approach workflow is getting triggered.
    The problem in this approach is after ¾ days it gives error when trying to kick off workflow from code with user who has not logged in as we are using this AD user only for kickoff purpose.
    InvalidOperationException:
    Operation is not valid due to the current state of the object
    MCTS Sharepoint 2010, MCAD dotnet, MCPDEA, SharePoint Lead

    There is a userprofile for the user and the issue is not a userprofile. We are using direct AD import and we have full sync every 5 minutes. The workflow gets kicked off using a fix user who never logs in but after 4/5 days the token or something gets expired
    and then we have to manually login with that user and then only code can kickoff workflow with that particular user.
    The problem in this approach is after ¾ days it gives error when trying to kick off workflow from code with user who has not logged in as we are using this AD user only for kickoff purpose.
    InvalidOperationException:
    Operation is not valid due to the current state of the object
    We can not kickoff with current user as current user can not be given contribute rights and we can not do it with system account as its not able to kickoff using system account by design of sp2013 workflow.
    So we need to know how to kcikoff workflow with a user who never logs in or logs in only for the first time and then never in production.
    Below code works for few days and then as user does not login with which we kick off workflow the token or something gets expired after 4/5 days.
    userToken = oSPWeb.EnsureUser(“UserAccountName”).UserToken;
    using (SPSite
    oSPSite = new
    SPSite(SPContext.Current.Web.Url,
    userToken))  //Site collection URL
    using (SPWeb
    oSPWeb = oSPSite.OpenWeb())  //Subsite URL
    SPList list = oSPWeb.Lists["Proposal"];
    try
                                oSPWeb.AllowUnsafeUpdates =
    true;
    SPListItem item = list.GetItemById(proposalID);
    var workflowServiceManager =
    new
    WorkflowServicesManager(oSPWeb);
    var workflowSubscriptionService = workflowServiceManager.GetWorkflowSubscriptionService();
                                //get
    all workflows associated with the list
    var subscriptions = workflowSubscriptionService.EnumerateSubscriptionsByList(list.ID);
    foreach (var
    workflowSubscription in subscriptions)
    if (workflowSubscription.Name ==
    "Proposal Workflow")
    //initiation parameters
    var inputParameters =
    new
    Dictionary<string,
    object>();
    inputParameters.Add("Comments",
    "TEST");
    inputParameters.Add("ItemId", item.ID);
    inputParameters.Add("WorkflowStart",
    "StartWorkflow");
    workflowServiceManager.GetWorkflowInstanceService().StartWorkflowOnListItem(workflowSubscription, item.ID, inputParameters);
    break;
                                oSPWeb.AllowUnsafeUpdates =
    false;
    catch (Exception
    ex)
                                Classes.Logger.WriteErrorLog("Sumbit",
    "kickoffWorkflow1", ex,
    MCTS Sharepoint 2010, MCAD dotnet, MCPDEA, SharePoint Lead

  • Dreamweaver CC crashes when switching from code view to design view

    I am experiencing a recent problem with a file I am currently working. When I switch from code view to design view Dreamweaver crashes and requests a shut down. Other files seem to work without a problem. This particular files has 3 cascading EdgeAnimation CC files that are selected by media queries. I can test the page online without a problem but not in design or live view.

    Since your new page didn't crash, this leads me to believe that you have some critical errors and/or conflicts in your other page(s).
    Try running your code through the W3C validation tools. 
    CSS - http://jigsaw.w3.org/css-validator/
    HTML - http://validator.w3.org/
    Also debug JavaScript. 
    JavaScript - http://www.jslint.com/
    Nancy O.

  • Using the SAP GUI from the NW2004s SneakPreview Download

    Hello,
    does anyone else have major problems with the SAPGUI from the NW2004 SneakPreview download page?
    Im getting a runtime error when logging on:
    Runtime Errors         MESSAGE_TYPE_X                                                                 
    Date and Time          24.12.2005 00:34:11                                                                               
    Short text                                                                               
    The current application triggered a termination with a short dump.                                                                               
    What happened?                                                                               
    The current application program detected a situation which really                                
         should not occur. Therefore, a termination with a short dump was                                 
         triggered on purpose by the key word MESSAGE (type X).                                                                               
    Error analysis                                                                               
    Short text of error message:                                                                     
         Control Framework : Error processing control                                                     
         Technical information about the message:                                                         
         Message classe...... "CNDP"                                                                      
         Number.............. 006                                                                               
    Variable 1.......... " "                                                                               
    Variable 2.......... " "                                                                               
    Variable 3.......... " "                                                                               
    Variable 4.......... " "                                                                               
    Trigger Location of Runtime Error                                                                    
         Program                                 CL_GUI_CFW====================CP                         
         Include                                 CL_GUI_CFW====================CM002                      
         Row                                     23                                                       
         Module type                             (METHOD)                                                 
         Module Name                             FLUSH                                                                               

    Hello Rich,
    the sap gui from the NW2004s SneakPreview page is on patchlevel 8. The problem is when i use the latest sap gui from the service marketplace (full install!) i cant event call the gui. Getting a error when doubleclicking on the SAP Gui icon.
    'The procedure entry point 'RfcResetTraceDir' could not be located in the dynamic link library 'LIBRFC32.dll' .'
    So actually since i installed the NW2004s on my local notebook the only sap gui "working" (at least i can call it) is the one from the NW2004s Sneakpreview page but im getting this error mentioned here on all systems! not only on the NW2004s system
    regards,
    Markus

  • Error synchroniz​ing with Windows 7 Contacts: "CRADSData​base ERROR (5211): There is an error converting Unicode string to or from code page string"

    CRADSDatabase ERROR (5211): There is an error converting Unicode string to or from code page string
    Device          Blackberry Z10
    Sw release  10.2.1.2977
    OS Version  10.2.1.3247
    The problem is known by Blackberry but they didn't make a little effort to solve this problem and they wonder why nobody buy Blackberry. I come from Android platform and I regret buying Blackberry: call problems(I sent it to service because the people that I was talking with couldn't hear me), jack problems (the headphones does not work; I will send it again to service). This synchronisation problem is "the drop that fills the glass". Please don't buy Blackberry any more.
    http://btsc.webapps.blackberry.com/btsc/viewdocume​nt.do?noCount=true&externalId=KB33098&sliceId=2&di​...

    This is a Windows registry issue, if you search the Web using these keywords:
    "how to fix craddatabase error 5211"       you will find a registry editor that syas it can fix this issue.

  • Database Server - SQL Access: Cannot connect from code but from SSMS

    Hi,
    I am using following connection string in my asp.net web.config:
    [Less than symbol] add name="FMMConnectionString" connectionString="Data Source=xxxxxxxxx,1234;Initial Catalog=Test1Db;User Id=Rajeev;Password=xxxxxxxxxxxxx;" providerName="System.Data.SqlClient" [Slash][Greater than symbol]
    The database is on remote database server. The sql user/ developer 'Rajeev' is deliberately given restricted permissions (to protect our schema) using following sql commands:
    GRANT ALTER,EXECUTE, SELECT,INSERT,UPDATE,DELETE ON SCHEMA ::dbo TO Rajeev
    DENY VIEW DEFINITION ON SCHEMA::dbo TO Rajeev;
    GRANT CREATE PROCEDURE TO Rajeev;
    GRANT CREATE FUNCTION TO Rajeev;
    DENY ALTER ON SCHEMA::dbo TO Rajeev; -- To disallow Rajeev to create objects on dbo schema but only create in Rajeev schema while still being able to select, insert, execute on dbo schema. 
    The above connection string works perfectly fine when used from Visual Studio> Server Explorer. I am able to execute following sql queries without issues. Same is true when using SQL Server Management Studio using Rajeev credentials.
    select top 100 * from XYZEmployees
    execute usp_GetMMBSchemeDetails '1' 
    The error I get in web page is following:
    The stored procedure 'usp_GetMMBSchemeDetails' doesn't exist.
    When I ran code using breakpoints to see what is happening, I see that when connection object is being instantiated, the connection state is being closed with following error:
    at System.Data.SqlClient.SqlConnection.GetOpenConnection()
    at System.Data.SqlClient.SqlConnection.get_ServerVersion()
    I turned off my firewall to see if it was blocking but it did not help. I tried using Visual Studio 2012 as well as Visual Studio 2013 but same issue showed up.
    Kindly let me know why I am able to execute sql queries from SSMS and Visual Studio's Server Explorer but not from application code. Is there something that needs to be enabled on remote database server so that the queries can run from code? I like to create
    more users like Rajeev with restricted permissions to develop my application. So kindly provide a solution if you know.
    Thanks,
    Pullet

    Thanks Everyone for your insights :) 
    RSingh, Your approach works when using SSMS, not when called from application code (example: asp.net code-behind page calling a stored proc using connection object).
    My requirement is, I only wanted developer to do front end programming without having the ability to look at backend sql objects definitions. He/she can call the sql objects in the program as needed. 
    I am able to finally solve this requirement by following approach. Hope it helps others. 
    1. Right-click Rajeev user in Database> Security>Users and unselect 'dbowner' from 'General' tab> 'Database Role Membership' section even though Default Schema shows up as Rajeev schema. Now, this user can't do anything on dbo schema of database
    (as well as in any other user's schema in this database).
    2. Ran above commands but excluded following command which was identified as root-cause.
    DENY VIEW DEFINITION ON SCHEMA::dbo TO Rajeev;
    3. Now ran a script that denies 'view definition' of dbo schema's tables. It loops through all tables and denies 'view definition' on each table. Adapted the script of http://blog.extreme-advice.com/2013/01/23/grant-view-defination-permission-to-all-stored-procedures-in-sql-server/.
    Now, the user Rajeev can execute dbo schema objects both from SSMS as well as from application code.
    4. DENY EXECUTE, SELECT ON SCHEMA::INFORMATION_SCHEMA TO Rajeev; -- Restricts Rajeev from executing INFORMATION_SCHEMA objects seen in SSMS.
    However one remaining open item is, I could not hide the system objects (which are part of sys schema) in SSMS. Ideally, I do not want Rajeev to execute the 'system views', 'system stored procedures', etc. When I execute same command (below command), it
    runs without errors but does not apply this restriction.
    DENY EXECUTE, SELECT ON SCHEMA::sys TO Rajeev;
    If you know the reason why it is happening like this, please kindly share.
    Cheers,
    Pullet
    Cheers | Pullet

  • In Smartform  split the contractor code

    In smartform how can we split the contractor code(adrc table) and display it in Template with 5 cells the field &GT_ADRC-POST_CODE3&

    Hi
    Why dont you create 5 data fields and move your post code into each of fields & display output in smartforms.
    sorry if i got your question wrong

  • GUI from an XML file

    Hello everybody,
    My problem is this: I have to do a GUI from an XML file. I am a begginer in JAVA, in GUI development and in XML. So... my situation is a bit difficult. What I have in mind is, if possible, to have a kind of function (that maybe already exists) that opens the XML file, read the whole document, keep the information in some variables and, from them, I can build the GUI using Swing. Is it possible this? Any help please, any idea?
    Thanks a lot!!
    Fran.

    Of course, this is possible. But what kind of "GUI XML" are you talking about? Is the XML given? Does it already conform to some GUI-XML-API? Give more infos!

  • Split audio from hdmi

    Hi there,
    I'd like to replace my first gen Apple TV with a new one.
    The problem is the lack of analog audio outputs.
    Currently I connect to my tv with hdmi and to my hifi with phono plugs.
    The new Apple TV only has hdmi and digital audio out which my hifi doesn't ....
    Is there a way I can split the audio out of the hdmi so I can play iTunes through the hifi with the TV switched off?
    Cheers Lizardpoint

    I'm not aware of any cables that split audio from HDMI and in any case it would still be digital audio. You might want to think about one of the items below and use the optical cable.
    DAC (Example Only - Not a recommendation or suggestion that this is suitable in your circumstances)

  • How to refer to an IB controller instance from code???

    Hi all. I know this must be simple but I have just never run into this before.
    When you drag an array controller from IB's palette into your top-level window, it instantiates it, right? All well and good - it's controlling my array and updating the tableView that is bound to its arrangedObjects just fine.
    Now I want to refer to it (the instance of the controller) from code. I have its class files, VoteeController.h and .m, but since I didn't make the instance, I don't know how to reference the instance. What I want to do is get the selection of the controller. That's all!
    I cannot code mySelection = [VoteeController selectedObjects], because that is a class object.
    How do I refer to the instance of this controller that IB instantiated when I dragged it onto the main window??
    I have the model object, playersArray, which has the data but doesn't have the selection since it is not a controller. I need to get the selected objects of the array controller that I made in IB.
    Thanks for any help!!

    Yes, I found a way to do it. So I am glad I can help. I will paste in the notes I took for myself.
    Ask any questions if the notes are not clear or do not work for you.
    NOTES:
    Settings for IB:
    TextModel NSObject:
    Class: TextModel (same as @interface)
    TextViewController Object Controller:
    Connections: content to TextModel
    Class: NSObjectController
    Bindings: none
    Content: control-dragged to TextModel.
    Keys: testString
    NOTE: Also works with no connection but setting in Bindings of Bind To Controller: TextModel, "blank" Controller Key and Key Path of self. ("TextModel.self") as Controller Content Content Object.
    NSTextView:
    Controller: TextViewController
    Connections: none
    Bindings:
    Controller: TextViewController
    Controller Key:selection
    Key Path: testString
    SUMMARY:
    1) Model Object - no connection needed. No keys needed. Just enter the Class name in the ID field (the Class name is the name of the Class whose instance contains the getters and setters for the object you want this Model Object to represent).
    2) Controller Object -
    A. Leave Class alone unless it makes new objects.
    B. No connections.
    C. Use Attributes panel to enter keys for the objects in the Model that you want.
    D. Bindings: bind to the Object Model. Leave the Controller Key blank and enter "self" in the Model Key Path.
    3) View Object -
    A. Leave Class alone (NSTextView)
    B. Turn off all RTF options if plain text.
    C. No connections.
    D. Bindings: bind to the View Controller. Set the Controller Key to Selection and the Model Key Path to the model key (e.g., testString).
    Now I've screwed up my Array->Two Array Controllers -> Two Table Views so they don't work any more. I had them working but with what I considered kludges (my goal in this project is to learn the BEST way to use Cocoa Bindings so as to have the absolute minimum glue code - I am aiming for the learning process, not a result necessarily - I already have a completely functional app in AppleScript Studio so I am under no "deadline."
    I had it working using your solution and setting some connections (control-drag) also, but I wanted to redesign it and not have to use connections (notice the TextView rules I posted above use no connections at all - only bindings).
    So if anyone reading this knows how to connect a single array as the Model to two NSArrayControllers as the Controllers, and the Controllers to two TableViews as the Views, chime in. I thought I had it down but it just doesn't load the array into the tableView. As usual, the array has its 7 elements in the debugger and in the NSLogs that I do.
    The part that keeps confusing me is that you have to set a class name for each IB element, and I don't want to have a bajillion Class files. I want one or two general Classes that can contain both an array and some strings and booleans and so forth - and I still cannot find the way to access an IB instance from code except the IBOutlet solution you provided. If that's the only way, fine; but I wanted to see if there is another way using Bindings. SURELY people who declare arrays need to obtain the selection for the arrays, and that exists ONLY in the Controller. So are we supposed to interact with the Controllers or not? How to get a controller's selection and use it on your Model array so you can manipulate with it? The controller instance doesn't even have a name.
    Anybody know anything about FIle's Owner? Several of the examples say to connect something to File's Owner but never say why. If File's Owner has access to all properties of the whole project, that would explain why it is used so often. But I do not think that is the case.

  • Split Output from Select into 2 different Cols

    Hi,
    I am new to oracle dev. Env Oracle 10g R2
    I need a help with the following.
    I have a select query that returns comma separated values.
    Column LIST1 in table svp_1.
    This needs to hold that data returned by the select query.
    Datatype of Column LIST1 varchar2(4000)
    I get the follwing error.
    ORA-19011: Character string buffer too small
    CREATE OR REPLACE PROCEDURE
    sale_temp( pType in Char,lDate in date) as
    cnt number;
    v_error_code NUMBER;
    v_error_msg VARCHAR2(2000);
    cursor c1 is select svp
    from sale
    where type = pType
    var1 c1%ROWTYPE;
    BEGIN
    UPDATE svp_1
    SET LIST1 = ( SELECT LTRIM( xmlagg (xmlelement (c, RTRIM(RELATED_SVP) || ',')).extract ('//text()'), ',' ) AS RELATED_SVP from (
    SELECT rtrim(BASE_SVP) BASE_SVP,
    rtrim(RELATED_SVP) RELATED_SVP
    from
    svp_enc se
    where
    se.effective date<= pDate
    and (se.expiration_date is null or se.expiration_date > plDate )
    and se.base_svp in
    ( var1.svp
    and se.RELATION_TYPE = '4'
    )group by base_svp)
    WHERE type = pType
    commit;
    dbms_output.put_line('UPDATE done' );
    end;
    end loop;
    close c1;
    END ;
    My requirement :
    In need to capture the data from the select query and update the column.
    The data needs to be returned as comma separated values.
    This data can also be split into 2 columns.....ie data split and updated into 2 cols ie LIST1 AND LIST2 ( can be added to existing table).
    What is the best way to do this?
    Is the below approach possilble?
    LOOP through cursor ...check the length of data....for the select query ....check length .if > 3990 byte.....then write into 2 plsql variables.....and update 2 cols....
    Is this apporach right, if so how to do that in the procedure ? Please give an example...
    Are there any other approaches...?
    All I need is to Split Output from Select into 2 different columns and avoid the ORA-19011: Character string buffer too small error.
    Thanks in advance.

    Re: ORA-19011: Character string buffer too small

Maybe you are looking for