Help using getters & setters

I am wanting to make a bean that will connect to a database and bring back data depending on what was entered in a html form. I have been told it would be easier if i make a bean that holds details of a single video. I have done this below, my question is in the servlet that connects to the database how will i use the result set to use these getters and setters?
package site;
public class vidBean
     //protected variables
     protected int recording_id;
     protected String title;
     protected String category;
     public void setRecId(int Rec)
          recording_id = Rec;
     public int getRecId()
          return recording_id;
... etc

something likeList<VidBean> videos = new ArrayList<VidBean>();
while(rs.next()) {
    VidBean video = new VidBean();
    video.setRecId(rs.getInd("id"));
    video.setTitle(rs.getString("title"));
    video.setCategory(rs.getString("category"));
}

Similar Messages

  • Getters & Setters in ABAP?

    In C# and in Java we have special functions that operate on private class data called getters and setters.  These are almost always public and allow the "outside" to interact safely with the private class data.  An example would be :
    [C#]
    public class Vehicle
         private string _make;
         private string _model;
         public string Make { get { return _make; } set { _make = value; } }
         public string Model { get { return _model; } set { _model = value; } }
    [Java]
    public class Vehicle
         private string _make;
         private string _model;
         public string getMake() { return _make; }
         pubic string setMake(string value) { _make = value; }
         public string getModel() { return _ model; }
         public string setModel(string value) { _model = value; }
    This allows controlled access to the private data (_make and _model).  For instance, I can put rules into the setters that makes sure the data is valid that's coming in from the outside, or in both the setter and getter that checks the user's permissions to see if they have the right to access this data.  It's simply a way to implement "encapsulation".
    Does ABAP use getters/setters?  If so, are they implemented as in Java or does ABAP have its own implementation?
    Thanks!

    No reason to be sorry, I understand that you simply didn't know.    Here is the run-down.  You can award points to any answers that you find helpful.  If one answer in particular has solved your problem, you then mark the radiobutton next to that answer which is blue, this gives the person 10 points.  If the answer was very helpful,  then select the green star, this is 6 points to the user, and if helpful, mark yellow star for two points.  If not helpful at all, then don't mark any.  You can also,  mark the thread as "Solved on your own".  This closes the thread by giving it a blue star, but doesn't give any points to anyone(which is what you have done to the other posts  )   It is very good that you have closed the threads, because this gives visibility that your problem was solved or your question is answered.  But awarding 10 points to the answer which solved your issue, will also close the thread.   
    You can go back and revisit your other threads and award points according.
    Help this helps, and welcome to SDN.
    Regards,
    Rich Heilman

  • Using 'variables.instance' structure and implicit getters/setters

    I am adopting the use of creating a variables.instance (I use 'variables.my') structure to separate instance data from the object, however I have a question when it comes to ColdFusion creating implicit getters and setters based on that object's defined properties.
    BEFORE, if I had a Name property, CF would create getName() and setName() for me, and it would update the variables.Name private variable accordingly in each.  But now that my variables are being stored in 'variables.my.Name', does this mean I can no longer use ColdFusion's implicit getters and setters? (because it would improperly be attempting to execute getName and be looking for variables.Name, when that data now exists in variables.my.Name?
    Are there any methodologies around that allow me to utilize CF's implicit getters/setters while using this 'my' instance variable and have them work with one another?

    Thanks for the confirmation Carl.
    How cool, then, would it be if ColdFusion 11 supported something like:
    <cfcomponent
         accessors="true"
         implicitpropertyprefix="my."
    That way I could specify "my." as the property prefix and when it goes to create those implicit getters and settings, it will concatenate that into 'variables.my.' as the prefix when it alters property values or returns them.

  • Using getters and setters

    I have a class which has public members and another class which directly access the first class's members. Now i want to change my first class in such a way that all its variables are private which has to be accessed by any other class using getters only. I want to write a new class which will change my second class in such a way that wherever the second class is accessing the firstclass's members directly, i need to incorporate getters of first class there. can you please guide me how to do this.

    i think you can try to rewrite the second class file with the alterations you need with:
    BufferedReader+FileReader, to read the second class
    PrintWriter+FileWriter, to write the newly created class
    replaceAll() in class "String", to make the modifications

  • Getters/Setters controversy

    So I'm going back and forth about whether or not to use getters and setters and any alternatives if I don't. I've read some articles that say getters and setters should be avoided at all cost.
    But I have an example program here, with a class called FlightInfo which basically holds all of the flight information such as flight date and the flight number. Wouldn't it be easiest to use getters and setters like the following:
    public class FlightInfo {
            private String date;
            private int flightNumber;
            public String getDate(){
                    return date;
            public setDate(String date){
                    this.date = date;
            public int getFlightNumber(){
                    return flightNumber;
            public setFlightNumber(String flightNumber){
                    this.date = flightNumber;
    }Is there any better alternative to this? Also, the flight date may change for a particular flight number.
    Thanks.
    Edited by: java_fan_69 on Dec 5, 2007 10:33 AM

    This:
            private String date;
            private int flightNumber;
            public String getDate(){
                    return date;
            public setDate(String date){
                    this.date = date;
            public int getFlightNumber(){
                    return flightNumber;
            public setFlightNumber(String flightNumber){
                    this.date = flightNumber;
            }has the same exact effect as this:
            public String date;
            public int flightNumber;They both allow you to access and modify the variables. I tend to favor using getters and setters, even when they don't add anything a) for consistency, so I can always find what I need in the methods, and b) in case they need to change later. For instance, you want to do some check on the flightNumber before setting it, or perhaps return the date in a different format in certain conditions.

  • Hard to Write Good Getters/Setters

    I am thinking about writing a complex wrapper to set and get any floats/strings/ints. Cause hate how OBJ-C handles these references/values and having to deal with headers and main files everytime something changes is a real big headache. On top I hate having to decide if your instance variable should be handled like a reference (which can be shared) or a value (which cannot). Most of the time you want value semantics, but implementation efficiency often makes folks choose reference semantics. Your decision effects how you write your getters/setters. Had to figure this out for myself, as I never found any good explanation of it.
    Not only do you have to deal with the reference/value semantics issue, but reference counting, threading and exceptions also complicate the issue.
    I am should just write a class to handle all this junk and use the #import so I dont have so much incredible redundant code that OBJ-C somehow needs.
    my plan:
    MyClass.SetInt(intname, x);
    SetInt, this will overwrite/declare an existing int variable by that name held in the class.
    x = MyClass.GetInt(intname);
    GetInt, this retrieves an existing int variable by that name held in the class - or returns nil if undeclared.
    but this is all fantasy, still .... I just might try it.

    well, i've been asked to do it.
    I'll make a short overview : I have a program that creates an XML file with some information about a workflow diagram. The company that requires this software wants to get the execution trace that create the XML file, apart from the XML itself, so they can freely modify it without the need of using my app. My app uses their libraries to write the XML. They could overwrite the XML directly but they already got the libraries and the parser to access each element.
    So, they want the execution trace of the code that generates the XML.I think you're going to be far better off inserting logging statements into your code, and building a small self-contained example from the output of those statements.
    If you don't want to do that, and are comfortable with JNI, you can write a trace agent using JVMTI
    Or, you can use aspect-oriented programming to add cutpoints to their methods, with a tool such as [Aspect-J|http://www.eclipse.org/aspectj/]
    There's also a "trace" command in JDB. Haven't used it, so can't tell you whether it will tell you everything you need.
    And there used to be a tracing interface that could be accessed from Java code. At least I seem to remember writing a trace utility in Java. Could be that it's available on the JRockit JVM and not Sun.

  • Getters & setters

    I am a newbie and trying to learn, I have a type & service table
    type
    t_id
    t_name
    blah
    blah
    service
    s_id
    t_id (fk)
    blah
    blah
    For a Add Screen, I have Type in a text field & JTable for the service (can be multiple for one type).
    Now normally when it is recommended to have getters & setters for everything, how do i have setters for the JTable (ie corresponding to the service table).
    I don't want to basically go back and forth the database 50 times , ie do the setter, insert to db, and repeat.
    Both are in the same screen as per the UI design ? How does everyone normally does this ?
    Thanks much

    Now normally when it is recommended to have getters & setters for everything, how do i have setters for the
    JTable (ie corresponding to the service table).That is not the normal recommendation:
    If and only if there is a compelling reason to expose the value of a field member of a class, you should do so through accessor methods, as this allows additional factilities (input validation, logging, etc) to be added and the implementation details to be changed.
    So it's not 'getters and setters for everything', but rather everything that needs to be accessed outside the class should use a getter or setter.
    Is there a compelling reason why the table should be accessible outside your GUI? Normally the view (in this case your JTable + the TableModel wrapper) asks a model (your data structure holding type and table, maybe reusing the generic ones supplied by Swing, maybe not) for the data, and doesn't expose the implementation of the view (the JTable) to the outside world.
    Imagine that, instead of using JTable, you changed your GUI to use a tree where the services were shown under the types; a local implementation change like that shouldn't effect any other part of your application, so only expose the parts of your view that are unchanged by such implementation details.
    Pete

  • Help using jar file!

    Help using jar file!
    Hello
    I have created a jar file by using
    jar cvmf Manifest.txt myjar.jar 1.class Mydirectory
    In 1.java file :I have used
    JEditorPane editor;
    editor.setPage(getClass().getResource("/Mydirectory/default.htm"));
    If I am only giving myjar.jar file to the client without Mydirectory then also it is working fine by showing default.htm in JeditorPane.
    But my problem is I want to use
    Runtime.getRuntime().exec("cmd /c start IEXPLORE"+targetstr) ;
    targetstr will be the filename with path of the default.htm
    If I am giving myjar.jar file with Mydirectory to the client it is working but I don't want to give Mydirectory to the client .
    What should I do?
    Is there any solution for this?
    Using another jar file which will include mydirectory can solve this problem?
    Is there any othe concept in java so that I wll be able to hide Mydirectory from client?
    Please help.

    It seems like you could extract the .htm file from the jar, either with Runtime.exec or using the Jar API classes.

  • Help using file sharing with different users accounts on same Macbook

    Hi, I just wanted a little help using the file sharing option. My wife and I had different users accounts on the same MacBook, but when I am trying to share my baby's picture from my documents folder for my wife to have the same picture, I can't find the way to do that; I am not been able to find my pictures on my wife's account. Is there any way that I could share a folder from my account and my wife to have the same files at the same time on her account?
    I mean, something like the smart play list on the itunes?
    Thank you

    You can't do that directly unless you change permissions on your whole Documents folder which is not a good idea. Your wife can see your Documents folder from her account by going to Users/yourusername/Documents. However, this folder has no read privileges for others except yourself by default so she won't be able to open it.
    rather than changing permissions on your Documents folder, you can place the pictures you want to share in Public folder in your home directory or in Users/Shared folder.

  • How to assign search help using ovs for select options for ALV in web dynpr

    how to assign search help using ovs for select options for ALV in web dynpro

    Hi,
    refer http://wiki.sdn.sap.com/wiki/display/WDABAP/InputhelpofObjectValueSelectioninWDABAP
    http://www.****************/Tutorials/WebDynproABAP/OVS/page1.htm
    and http://wiki.sdn.sap.com/wiki/display/Snippets/WebDynproAbap-OVSsearch+help
    Thanks,
    Chandra

  • How to create Search Help using more than 1 table

    Hi all,
    I need to create a search help using more than 1 table.
    Eq:-   Itable1 contains the data and Table2 contains the description of a field.
    In my search help i require A field from Table1 and For the corresponding field description from Table2.

    Hi,
    You can do this with the help of collective search help.
    Collective search helps:- Combination of elementary search helps. When we need to fetch data based on multiple selection criteriau2019s. More than one tables are Selection from multiple tables 
    Steps for creating collective search help.
    1) Enter the search help name and click on create.
    2) Choose Collective search help radio button option as the search help type.
    3) Enter the search help parameters.
    Note that there is no selection method to be entered for a collective search help.
    4) Instead of the selection method, we enter the included search helps for the collective search help.
    5)We need to assign parameters for each of the included search helps.
    6) Complete the parameter assignment by clicking on the push button.
    7) Collective search help offers the user to obtain F4 help using any of the included search helps.
    Hope this will help you:
    Reagrds:
    Alok

  • Just brought a ipad2 need some help using it.

    Need some help using ipad2

    Also, Good Instructions http://www.tcgeeks.com/how-to-use-ipad-2/
    Apple - iPad - Guided Tours
    http://www.apple.com/ipad/videos/
    Watch the videos see all the amazing iPad apps in action. Learn how to use FaceTime, Mail, Safari, Videos, Maps, iBooks, App Store, and more.
    You can download this guide to your iPad.
    iPad User Guide for iOS 5
    http://itunes.apple.com/us/book/ipad-user-guide-for-ios-5/id470308101?mt=11
     Cheers, Tom

  • I need helping using iAds in my application.

    I need helping using iAds in my application. I currently am not using any storyboards. I am using Sprite builder for my UI.
    I attatched an image ot show all the different file name I have.
    Everyone is being used & they all work fully.
    The "iAdViewController.h & .m" files are just example codes I looked up and was messing with so that my iAd can work.

    I wouldn't even be able to use the Mathscript node in an executable? 
    What I am trying to do is make a user configurable data stream. 
    They tell me how many bytes are in the stream and what parameters they
    want to be put in to it.  Currently I have to make vi's that are
    called dynamicaly to make the parameters.   Then recompile
    the code and send it to them.  This is somewhat of how the config
    file is set up so I know how to make the data.
    Data_Type  foo
    Bytes 30
    parameter_name        
    function           
       byte#          format
    sync              
    foo_sync            
    29               int
    time                              
    foo_time             
    1,2,3,4       double
    If I can't use MathScript to allow the user to make there own functions
    is there another way that I might be able to do this so I do not have
    to recompile the code atleast?  Were I might just be able to make
    the new function and send that to them.
    Any Idea would be great.

  • Help, used ipod will lock up mitunes when I try to add songs from library will stop after 20-30- songs How do I fix this?

    Help, used ipod will lock up mitunes when I try to add songs from library will stop after 20-30- songs How do I fix this?

    Need more info to be of any assistance
    Which version of iTunes are you using?
    What is the iPod Software version as shown in the iTunes summary page?
    Which model of iPod classic are you using?

  • Help Using Labview to control Kikusui power supply with a PIA4850 controller

    HI I need some help using Labview to control 4 Kikusui power supplies. We have a PIA4850 Kikusui power supply controller. I can use the visa test panel and see the PIA4850 but can see any of the power supplies. I have very limited use of Labview and only wrote a couple programs using GPIB. The PIA4850 is a USB controller and can control up to 32 PS. I can get it to work with a Excel demo software that came with the controllers so I know that it is working. Any help will be appreciated. I am using LabView 8.2 and have updated to the Ni-DAQ 9.0. I have a program that I need to incorporate the PIA4850 into once I figure out how to operate it. Thanks in advance.

    HI and thanks for the help. I did get one power supply to work but have another problem. I need to control 4 power supplies at the same time and can only operate the one that is addressed N5!C1. If I set the other to N6!C1 and so on I get an error stating
     “Error -1074135008 occurred at ki4800_2 Configure Voltage Level.vi Possible reason(s):IVI Error in the method "get_Item" in the component "Kikusui4800". E_IVI_UNKNOWN_CHANNEL_NAME: Unknown channel name (N6!C1)”
      I am assuming that I should be able to change the node number and that will change the supply that I need to use. Everything works great if I use N5!C1 I can change any of the supplies to address 5 and can control it with no problem. I can even have multiple supplies with the same address N5!C1 (don’t think I should do that) and change them all at once. I need independent control of each supply.
      I am in a pinch here and need to figure it out but could use some help. Any ideas will be greatly appreciated.
      Thanks
    GBlair
    Attachments:
    KIKUSUI PS.llb ‏179 KB
    Kikusui Ps Controller.JPG ‏63 KB

Maybe you are looking for

  • SpeedGrade doesn't open after installed

    I can't get SpeedGrade CC to open on my Alien Laptop. I more than meet the system requirements with a i7 240GHz 64 bit processor, win 7 with serPac 1, 12Gigs Ram, tons of HD space, 1440X900 display (1600X900 default), GPU card GeForce GT650M and quck

  • Ipod touch wont boot up

    My ipod touch 4th gen just blinks on and off the apple logo, it wont work?

  • ALV problem with zeros

    Hi guys,    I have a problem in ALV. There is character field which is company code , whenever the value is '000'or 010' it is displaying as '0' or '10'. can you please help me on this. here is the field catelog for this... it is really urgent. CLEAR

  • Lock Selected objects

    Hi Any one please help me to use lock option in javascript i want to lock selected objects Thank APPU

  • How to re-load plug-ins when upgrading?

    I recently upgraded to PSE 10.  Cannot locate/add to my Filter Menu my Topaz plug-in I had with PSE-9.  Help?