Parameters in Constructors

Hi,
I have designed my application in such a way that a particular object is constructed using a number of dynamic parameters.
The number is so huge currently and may go up during enhancements. This does not seem to be elegant for a constructor.
Following is an example:
DisplayAllParkedWebState(String serviceVarName, String scopeVarName,String queryVarName,
String onAction, Map fixedValues,Set display,String commonTriggerName)
Usage of a Collection was not possible as the arguments are homogeneous.
Can you suggest me a better way to construct this object.
Thanks in advance,
Rajesh

OK.
I'm not that experienced with web components, I'd suggest you ask the question in the Java Server Pages or the Java Servlet Technology forum. There are lots of people writing HTML generating Java out there.
Just on a general note, I get the impression that the code you have that generates the object in question seems to need to know very much about how the object works since it needs to send so many specific parameters. This would effectively mean that you're in fact not encapsulating the web page display logic in the display object, you're spreading it out. In general, these things are usually designed this way:
"View"
"Controller
"Model"
The "view" in this case would be your object that generates HTML (which will be viewed by the user).
The "model" basically stores the dynamic data that the view(s) display.
The "controller" is usually the object that invokes the view and tells it to display itself, for instance a dispatches within your application that parses URLs and determines which web page (which view object) to display.
The view object is simply created with a reference to the model. It is then up to the view to fetch the data it needs via the model's interface, which you'll need to design according to the data that is to be accessed from it.
Hope this helps
/C

Similar Messages

  • Passing array of parameters to constructor

    I'm writing a script which facilitates interaction between javascript and an already existing flash library. One of the things I need to do is create an instance of class x, where class x can be one of a large number of classes. The constructors for these classes each take different numbers of parameters. I want to pass the parameters in from Javascript as an array, and I was hoping that there would be a way to pass the array contents into the constructor as parameters. I tried using apply, but it's not available on constructors.
    The only other option I know of is to write a large case statement full of constructors, and for each parameter pass an integer indexed array element. Is there any other way?

    Your going to have to unpack your array no matter what, so no.
    You can make your class factory with your huge case, or, if you have the source for your lib you could modify the constructor, but its the same amount of work:
    Was:
    public function MyClass(s:String, n:Number, d:Date){...}
    To:
    public function MyClass(s:*, n:Number=0, d:Date=nul){
      <case code here>
    If you have a decent platform, or even javascript, you could maybe think about writing a parser that will generate the class factory case based on the constructor signatures.

  • Placing a instance from the library and parameters?

    Ok, here is just a general question about the use of classes in flash. Say I have a class called ClassA that wants two parameters passed in.
    So i create an instance of it and add it to the stage with code like this:
    var myInstance:ClassA = new ClassA("something", "somethingelse");
    addChild(myInstance);
    That works all well and good!
    Now, is there a way i could manually place an instance of ClassA from the library palette and tell it the two parameters?
    I hope this is clear.

    Why would you do that?
    In any case, when you grab a symbol from the library - constructor is automatically invoked. Thus - you cannot pass parameters into constructor. Nevertheless, you can expose corresponding parameters as API and set them on an instances that was placed on timeline at authoring.

  • Summing up a Column in ALV report

    Hi All,
    I have developed an ALV Report which will display Invoices and other details.
    Now i need to display the sum of NETWR column, if user wish to select that column and click the "SUM" icon.
    As of now, if i select the NETWR column and click 'SUM" column, i am getting Runtime error.
    How to resolve this issue?
    Regards
    Pavan

    Hi Pavan,
    ALV GRID CONTROL:
    This task is performed by the SAP Control Framework.
    The R/3 System allows you to create custom controls using ABAP Objects. The application server is the Automation Client, which drives the custom controls (automation server) at the front end.
    If custom controls are to be included on the frontend, then the SAPGUI acts as a container for them.
    Custom controls can be ActiveX Controls or JavaBeans.
    The system has to use a Remote Function Call (RFC) to transfer methods for creating and using a control to the front end.
    ABAP objects are used to implement the controls in programs.
    An SAP Container can contain other controls (for example, SAP ALV Grid Control, Tree Control, SAP Picture Control, SAP Splitter Control, and so on). It administers these controls logically in one collection and provides a physical area for the display.
    Every control exists in a container. Since containers are themselves controls, they can be nested within one another. The container becomes the parent of its control. SAP containers are divided into five groups:
    SAP custom container: Displays within an area defined in Screen Painter on screens or sub screens.
    Class: CL_GUI_CUSTOM_CONTAINER
    SAP dialog box container: Displays in a modeless dialog box or as a full screen. Class:
    CL_GUI_DIALOGBOX_CONTAINER
    SAP docking container: Displays as docked, resizable sub-window with the option of displaying it as a modeless dialog box. Class: CL_GUI_DOCKING_CONTAINER
    SAP splitter container: Displays and groups several controls in one area - that is, splits the area into cells Class: CL_GUI_SPLITTER_CONTAINER
    SAP easy splitter container: Displays controls in two cells, which the user can resize using a split bar. Class: CL_GUI_EASY_SPLITTER_CONTAINER.
    In the control, you can adjust the column width by dragging, or use the 'Optimum width' function to adjust the column width to the data currently displayed. You can also change the column sequence by selecting a column and dragging it to a new position.
    Standard functions are available in the control toolbar. The details display displays the fields in the line on which the cursor is positioned in a modal dialog box.
    The sort function in the ALV Control is available for as many columns as required. You can set complex sort criteria and sort columns in either ascending or descending order.
    You can use the 'Search' function to search for a string (generic search without *) within a selected area by line or column.
    You can use the 'Sum' function to create totals for one or more numeric columns. You can then use the "Subtotals" function to set up control level lists: You can use the 'Subtotal' function to structure control level lists: select the columns (non-numeric columns only) that you want to use and the corresponding control level totals are displayed.
    For 'Print' and 'Download' the whole list is always processed, not just the sections displayed on the screen.
    You can define display variants to meet your own specific requirements. For information on saving variants, see 'Advanced Techniques'.
    The ALV grid control is a generic tool for displaying lists in screens. The control offers standard functions such as sorting by any column, adding numeric columns, and fixed lead columns .
    Data collection is performed in the program (with SELECT statements, for example) or by using a logical database. The data records are saved in an internal table and passed on to the ALV control along with a field description.
    The field description contains information about the characteristics of each column, such as the column header and output length. This information can defined either globally in the Dictionary (structure in the Dictionary) or in the field catalog in the program itself. You can also merge both techniques.
    The ALV link is a standard function of Query and QuickViewer. If multiline queries or Quick View lists have been defined, they will automatically be compressed to a single line and output in the ALV control as a long, single line list.
    Use Screen Painter to create a sub screen container for the ALV grid control. The control requires an area where it can be displayed in the screen. You have to create a container control that determines this area.
    Use the corresponding icon in the Screen Painter layout to create the container control. The size of area "MY_CONTROL_AREA" determines the subsequent size of the ALV control.
    The valid GUI status must be set at the PBO event in the flow logic of the ALV subscreen container.
    The OK_CODE processing for the cancel functions must be programmed at the PAI event.
    The reference variables for the custom container and the ALV grid control must be declared.
    To create reference variables, use ABAP statement TYPE REF TO .
    The global classes you need to do this are called cl_gui_custom_container (for the custom container control) and cl_gui_alv_grid (for the ALV grid control).
    The global classes are defined in the Class Builder. You can use the Class Builder to display information for the methods, their parameters, exceptions, and so on.
    Use ABAP statement CREATE OBJECT to create the objects for the container and the ALV control. Objects Are instances of a class.
    When an object is created (CREATE), method CONSTRUCTOR of the corresponding class is executed. The parameters of method CONSTRUCTOR determine which parameters have to be supplied with data when the object is created. In the above example, object alv_grid is given the name of the container control (g_custom_container) in exporting parameter i_parent, which links the two controls. For information on which parameters method CONSTRUCTOR possesses and which of these parameters are required, see the Class Builder.
    Objects should only be created once during the program. To ensure that this is the case, enclose the CREATE OBJECT statement(s) in an IF IS INITIAL. ... ENDIF clause. The objects must be generated before the control is displayed for the first time - that is, during the PBO event of the ALV subscreen container.
    To display the requested dataset in the ALV control, the data must be passed on to the control as an internal table, and a field description must exist indicating the order in which the columns will be output.
    In the simplest case, the field description can use a structure from the Dictionary. The Dictionary also determines the technical field attributes like type and length, as well as the semantic attributes like short and long texts. The ALV control uses this information to determine the column widths and headers. The column sequence is determined by the field sequence in the structure.
    If no suitable structure is active in the Dictionary, or you want to output internal program fields in the control, then you will have to define information like the output length and column header in the field catalog.
    In a typical program run, the dataset is read first (SELECT ....), the internal table is filled with the data to display (... INTO TABLE ...), and ABAP statement CALL SCREEN is then used to call the ALV sub screen container.
    The data transfer to the ALV control takes place during the call of method
    set_table_for_first_display from class cl_gui_alv_grid. The method call must be programmed at the PBO event of the ALV subscreen container.
    The name of the Dictionary structure that supplies the field description is specified in exporting parameter i_structure_name. The name of the internal table that contains the data records to display is specified in changing parameter it_outtab.
    The field description for the ALV control can be ta ken from an active Dictionary structure (fully automatic), by passing a field catalog (manual), or through a mixture of the two options (merge).
    The field catalog is in internal table with type lvc_t_fcat. This type is defined globally in the Dictionary.
    Each line in the field catalog table corresponds to a column in the ALV control.
    The field characteristics (= column characteristics) are defined in the field catalog. The field catalog is in internal table with type lvc_t_fcat. Each line that is explicitly described in the ALV control corresponds to a column in the field catalog table.
    The link to the data records to output that are saved in internal table is established through field name . This name must be specified in column "fieldname" in the field catalog.
    This field can be classified through a Dictionary reference (ref_table and ref_field) or by specifying an ABAP data type (inttype).
    Column headers and field names in the detail view of an ALV control line can be determined in the field catalog in coltext and seltext, respectively.
    The position of a field during output can be determined with col_pos in the field catalog.
    If you want to hide a column, fill field no_out with an "X" in the field catalog. Hidden fields can be displayed again in a user display variant.
    Icons can be displayed in the ALV control. If you want a column to be interpreted as an icon, then the icon name must be known to the program (include .) and icon = "X" must be specified for this column in the field catalog.
    The above example shows a semi-automatic field description: Part of the field description comes from the Dictionary structure (sflight), while another part is explicitly defined in the field catalog (gt_fieldcat).
    The field catalog (internal table) is filled in the program and is passed on together with the name of the Dictionary structure during the method call. The information is merged accordingly in method set_table_for_first_display.
    For a user to save display variants, parameters is_variant and i_save must be passed on during method call set_table_for_first_screen. To assign display variants uniquely to a program, at least the program name must be supplied in the transferred structure (gs_variant).
    Program names can be up to 30 characters long.
    If you only pass on the current parameters for is_variant, then existing variants can be loaded, but no new ones can be saved. If you use parameter i_save, you must pass on a variant structure with is_variant.
    I_SAVE = SPACE No variants can be saved.
    I_SAVE = 'U' The user can only save user-specific variants.
    I_SAVE = 'X' The user can only save general (shared) variants.
    I_SAVE = 'A' The user can save both user-specific and general (shared) variants.
    You can use parameter is_layout of method set_table_for_first_display, for example, to define the header in the ALV control and the detail display.
    To do this, define a query area in the program in accordance with Dictionary structure lvc_s_layo, and pass on the text to display in field -grid_title or -detailtitl.
    If you want to create print lists with zebra stripes, set field -zebra to "X". You can display a print preview for print lists by requesting standard function "Print".
    All parameters of method SET_TABLE_FOR_FIRST_DISPLAY from global class
    CL_GUI_ALV_GRID are defined in the Class Builder.
    Events are defined in global class cl_gui_alv_grid; you can use these events to implement user interaction within the program. To respond to a double -click on a table line, you must respond to event DOUBLE_CLICK.
    You receive control in the program, allowing you to implement interactive reporting - such as a full screen details list. The events for cl_gui_alv_grid are located in the Class Builder.
    To define an implement a local class in the program, you use a handler method. In this handler method, you program the functionality to trigger by a double -click in the output table.
    To activate a handler method at runtime, a class or an object from that class registers itself with an event using command SET HANDLER. The names of the IMPORTING parameters in the handler method correspond to the names of the EXPORTING parameters of the related event.
    In the above example, the local class is LCL_ILS and the handler method is ON_DBLCLICK. An object - ALV_DBLCLICK - is created and registers itself for event DOUBLE_CLICK.
    You can query parameter e_row-index to determine which output line was requested by the double -click. This parameter corresponds to the line number of the output table (internal table with the data records to output). If you need information for the selected line, you have to read it with READ TABLE itab INDEX e_row-index.
    This subsequent read in the output table generally corresponds to the HIDE area in conventional reporting. You first have to make sure that the user has double -clicked a line in the output table (similar to the valid line selection with the HIDE technique).
    A field group can contain global data objects, but not data objects that have been defined locally in a subroutine or function module.
    You can use INSERT to specify both fields and field symbols. This makes it possible to dynamically insert a data object referred to by a field symbol into a field group at runtime. Any field symbols that have not been assigned are ignored, which means no new field is inserted into the field group.
    The EXTRACT statement writes all the fields of a field group as one record to a sequential dataset (transport takes place with similarly named fields). If a HEADER field group is defined, then its fields are placed ahead of each record as sort keys. You can then sort the dataset with SORT and process it with LOOP ...ENDLOOP. In this case, no further EXTRACT is possible.
    The INSERT statement is not a declarative statement: This means field groups can also be expanded in the program flow section.
    As soon as the first dataset of a field group has been extracted with EXTRACT, that field group can no longer be expanded with INSERT. In particular, the HEADER field group cannot be expanded after the first EXTRACT (regardless of the field group).
    When the GET events are processed, the logical database automatically writes hexadecimal zeros in all the fields of a node when it returns to an upper-level node in the hierarchy. Since the HEADER normally contains sort fields for all field groups, these hexadecimal zeros in the HEADER serve as a type of hierarchy key: The more zeros there are, the further up in the control level hierarchy you go.
    &#61550;&#61472;The SORT statement sorts the extract dataset in accordance with the defined field sequence in field group HEADER. The addition BY ... sets a new sort key.
    Each must be either a field of field group HEADER or a field group that consists only of fields of the field group HEADER. You can use the additions ASCENDING and DESCENDING to determine whether the fields are sorted in ascending (default) or descending order.
    Fields containing X'00' in the logical databases are always displayed before all other values during a SORT.
    Processing of an extract dataset always takes places within a LOOP. The contents of the extract dataset field are placed in program fields with the same names.
    The group change always involves the fields of the HEADER. Single record processing for extract datasets is performed using language element AT ( = field group).
    CNT() is not a statement, but instead a field that is automatically create d and filled when is a non-numeric field from field group HEADER and is part of the sort key. At the end of the group, CNT() contains the number of different values that the field recorded in this group level.
    SUM() is not a statement, but instead a field that is automatically created and filled when is a numeric field of an extract dataset. At the end of the group, SUM() contains the control total of field .
    *** and CNT are only available at the end of the group level or at AT LAST.
    Single record processing for extract datasets AT WITH is only performed when field group is immediately followed by field group in the temporary dataset.
    Loops over an extract dataset cannot be nested. However, several contiguous loops are permitted.
    The sequence of the control level changes within the LOOP must correspond to the sort sequence.
    Totals can only be calculated within control footer processing.
    Extracts allow only appends (EXTRACT), sorting (SORT) and sequential processing (LOOP).
    Once a SORT or LOOP has occurred, the intermediate dataset is frozen and cannot be expanded with EXTRACT. Operations that insert into or delete from EXTRACT datasets are not supported.
    Extracts allow for several record types (FIELD-GROUPS) with fields that can be set dynamically (INSERT is not a declarative statement!). Internal tables have a single, statically-defined line type.
    Internal tables use the sequence of table fields according to the declaration for the hierarchy of the control leve l. The control level structure for internal tables is therefore static, and is independent of which criteria were used to sort the internal table.
    Extracts do not depend on the field sequence for control level processing: a re-sort or a completely different control level process can take place. The control level structure for extract datasets is therefore dynamic. It corresponds exactly to the sort key of the extract dataset. The sort key is the sequence of fields from the field group HEADER, and is used to sort the extract dataset.
    Extracts rely on the compiler to determine which combinations of group levels and a cumulating field the control level totals desire. The desired control level totals are determined by the processing of LOOP ... ENDLOOP blocks. Internal tables build the control level total with the SUM statement.
    This procedure leads to high resource depletion for totaling control levels in internal tables.
    Regards,
    Chandru

  • How to pass Objects from Java App to JavaFX Application

    Hello,
    New to the JavaFX. I have a Java Swing Application. I am trying to use the TreeViewer in JavaFX since it seems to be a bit better to use and less confusing.
    Any help is appreciated.
    Thanks
    I have my Java app calling my treeviewer JavaFX as
    -- Java Application --
    public class EPMFrame extends JFrame {
    Customer _custObj
    private void categoryAction(ActionEvent e)   // method called by Toolbar
            ocsCategoryViewer ocsFX;    //javaFX treeviewer
            ocsFX = new ocsCategoryViewer();    // need to pass in the Customer Object to this Not seeing how to do it.
                                                  // tried ocsFX = new ocsCategoryViewer(_custObj) ;    nothing happened even when set this as a string with a value
    public class ocsCategoryViewer extends Application {
    String _customer;
    @Override
        public void start(Stage primaryStage) {
         TreeView <String> ocsTree;
         TreeItem <String> root , subcat;
      TreeItem <String> root = new TreeItem <String> ("/");
            root.setExpanded(true);
             ocsTree = new TreeView <String> (root);
             buildTree();     // this uses the Customer Object.
            StackPane stkp_root = new StackPane();
            stkp_root.getChildren().add(btn);
            stkp_root.getChildren().add(ocsTree);
            Scene scene = new Scene(stkp_root, 300, 250);
            primaryStage.setTitle("Tree Category Viewer");
            primaryStage.setScene(scene);
            primaryStage.show();
        public static void main(String[] args) {
            _customer = args[0];      // temporarily trying to pass in string.
            launch(args);

    JavaFX and Swing integration is documented by Oracle - make sure you understand that before doing further development.
    What are you really trying to do?  The answer to your question depends on the approach you are taking (which I can't really work out from your question).  You will be doing one of:
    1. Run your Swing application and your JavaFX application as different processes and communicate between them.
    This is the case if you have both a Swing application with a main which you launch (e.g. java MySwingApp) and JavaFX application which extends application which you launch independently (e.g. java MyJavaFXApp).
    You will need to do something like open a client/server network socket between the applications and send the data between them.
    2. Run a Swing application with embedded JavaFX components.
    So you just run java MySwingApp.
    You use a JFXPanel, which is "a component to embed JavaFX content into Swing applications."
    3. Run a Java application with embedded Swing components.
    So you just run java MyJavaFXApp.
    You use a SwingNode, which is "used to embed a Swing content into a JavaFX application".
    My recommendation is:
    a. Don't use approach number one and have separate apps written in Swing and Java - that would be pretty complicated and unwarranted for almost all applications.
    b. Don't mix the two toolkits unless you really need to.  An example of a real need is that you have a huge swing app based upon the NetBeans platform and you want to embed a couple of JavaFX graphs in there.  But if your application is only pretty small (e.g., it took less than a month to write), just choose one toolkit or the other and implement your application entirely in that toolkit.  If your entire application is in Swing and you are just using JavaFX because you think its TreeView is easier to program, don't do that; either learn how to use Swing's tree control and use that or rewrite your entire application in JavaFX.  Reasons for my suggestion are listed here: JavaFX Tip 9: Do Not Mix Swing / JavaFX
    c. If you do need to mix the two toolkits, the answer of which approach to use will be obvious.  If you have a huge Swing app and want to embed one or two JavaFX components in it, then use JFXPanel.  If you have a huge JavaFX app and want to embed one or two Swing components in it, use a SwingNode.  Once you do start mixing the two toolkits be very careful about thread processing, which you are almost certain screw up at least during development, no matter how an experienced a developer you are.  Also sharing the data between the Swing and JavaFX components will be trivial as you are now running everything in the same application within the virtual machine and it is all just Java so you can just pass data around as parameters to constructors and method calls, the same way you usually do in a Java program, you can even use static classes and data references to share data but usually a dependency injection framework is better if you are going to do that - personally I'd just stick to simply passing data through method calls.

  • Multi-touch in java

    Hi,
    I am trying to build a project with multi-touch capabilities using java. I did some research and thought mt4j is promising.
    But now I find it difficult to design a page with swing radio buttons and buttons etc., I want to use swing components such as Radio buttons with mt4j framework but I couldn't accomplish it.
    Can you please let me know if there is a way to develop a multi touch application in java using swing alone or any other good way of developing multi-touch features .

    how can we pass arguments to the run ()method?Create classes which implement Runnable that take your runtime parameters as constructor arguments and store them.
    eg: if your single thread method is   static void foo (int quantity, String name) {
        for (int i=0; i<quantity; i++) {
          System.out.println(name);
    // caller code
      foo(7, "wombats");Then you can make a runnable implementation thus:public class Foo implements Runnable {
      final int quantity_;
      final String name_;
      public Foo (int quantity, String name) {
        quantity_ = quantity;
        name_ = name;
      public void run () {
        for (int i=0; i<quantity_; i++) {
          System.out.println(name_);
    // caller code
      new Thread(new Foo(7, "wombats")).start();
    You could overload this method to take parameters in
    your class that implements the Runnable interface,
    and then call the base run() method.I don't get what you mean by this; Runnable is an interface so there is no base class run() method, and a run() overloaded with extra parameters method wouldn't get called by the thread.
    Pete

  • Trouble rationalizing use of multi-threading in run of the mill servlets

    Hey everybody,
    While spending time writing an internal wiki article on servlets for work, I asked myself a very basic question: What does multi-threading buy average servlets where the business logic requires procedural handling of the request?
    Don't get me wrong: I appreciate the fact that servlet containers spawning a new thread being less expensive than spawning an entirely new process is helpful and efficient. Coming from a background in PHP, it is great how servlets maintain persistence. However, as more of my coworkers are required to gain proficiency in Java and designing servlets, it is a question that many will ask and aside from having real-time processing of data files and other arduous tasks, I cannot think of any instances of where multi-threading benefits the application.
    What are some of the ways that you are using multi-threading with web applications?
    How would you explain why and where you would want to use multi-threading to someone?
    Thank you in advance for your insight,
    Andy

    how can we pass arguments to the run ()method?Create classes which implement Runnable that take your runtime parameters as constructor arguments and store them.
    eg: if your single thread method is   static void foo (int quantity, String name) {
        for (int i=0; i<quantity; i++) {
          System.out.println(name);
    // caller code
      foo(7, "wombats");Then you can make a runnable implementation thus:public class Foo implements Runnable {
      final int quantity_;
      final String name_;
      public Foo (int quantity, String name) {
        quantity_ = quantity;
        name_ = name;
      public void run () {
        for (int i=0; i<quantity_; i++) {
          System.out.println(name_);
    // caller code
      new Thread(new Foo(7, "wombats")).start();
    You could overload this method to take parameters in
    your class that implements the Runnable interface,
    and then call the base run() method.I don't get what you mean by this; Runnable is an interface so there is no base class run() method, and a run() overloaded with extra parameters method wouldn't get called by the thread.
    Pete

  • RegisterClassAlias

    I have defined a custom class:
    public class Chat
    public function Chat (tye:int, date:Date)
    I have to save some object of this class in a SharedObject
    (or in a file with AIR), so I tried using
    registerClassAlias("ChatAlias", Chat).
    The problem is: when I try to read the sharedObject or the
    file, I receive the following error message:
    Error #1063: Argument count mismatch on tcl.mainclasses::Chat().
    Expected 2, got 0.
    What can I do to solve this problem? Thanks!!!

    It's really strange when you need to look for good example on forums because you can't find it in official documentation .
    Looks like you additionaly need to implement IExternalizable interface when your class needs to have parameters in constructor even if all fields of the class are public. At the same time you need to use default values for all parameters because: "Flash creates an instance of the object automatically before calling the object's readExternal() method".
    You can find example here: http://forums.adobe.com/message/3085267#3085267
    P.S.
    Shame on you Adobe, you must seriously improve quality of your documentation!

  • How to call procedure with Object types in java

    Hi,
    We have procedure declaration as follows
    ===============
    TYPE TEST_TYPE AS OBJECT (NAME VARCHAR2(10));
    TYPE TESTTYPE1 AS object (student1 TESTTYPE,student2 TESTTYPE,student3 TESTTYPE);
    TYPE rect AS OBJECT
    -- The type has 3 attributes.
    length NUMBER,
    width NUMBER,
    area NUMBER,
    -- Define a constructor that has only 2 parameters.
    CONSTRUCTOR FUNCTION rect(length NUMBER, width NUMBER)
    RETURN SELF AS RESULT
    PROCEDURE G(obj1 in TESTTYPE1,obj2 out rect) as
    n1 testtype;
    n2 testtype;
    n3 testtype;
    n4 testtype;
    begin
    obj2 := NEW rect(10,20,200);
    n1 := obj1.student1;
    n2 := obj1.student2;
    n3 := obj1.student3;
    obj2.length :=20;
    end;
    =====================================================
    I am not able to call the procedure in java code as I cannot figure out which out parameter type will it be registered using registeroutparameter. using cursor or struct type fails.
    please let me know how I can pass values from stored procedure with objects to java.

    I'm not sure what you're trying to accomplish with your procedure, but in general, this is an example of how you could use oracle.sql.STRUCT.
    First, prepare your java.sql.CallableStatement using java.sql.CallableStatement cStmt = java.sql.Connection.prepareCall({ call G(?, ?) });
    Note that you don't have to use the OracleCallableStatement. The java.sql.CallableStatement will work just fine.
    For the IN parameter, you need to create three TEST_TYPE objects. Then you need to create one TESTTYPE1 object.
    These will all be instances of oracle.sql.STRUCT.
    To create a oracle.sql.STRUCT object you need a descriptor and a set of attributes. For example, to create a TEST_TYPE object you would do the following
    1. StructDescriptor sd = StructDescriptor.createDescriptor("TEST_TYPE", java.sql.Connection).
    2. Add a VARCHAR2 attribute to an array of attributes (e.g. Object[] attributes = new Object[]{"Student Name"})
    3. oracle.sql.STRUCT struct = new oracle.sql.STRUCT(sd, java.sql.Connection, attributes)
    Then do something similar to create the TESTTYPE1 object, except that the attribute array will contain three instances of TEST_TYPE struct objects.
    To bind the IN parameter you need to use the java.sql.CallableStatement.setObject(1, <Instance of TESTTYPE1 object>).
    To register the OUT parameter, you need to call java.sql.CallableStatement.registerOutParameter(2, oracle.jdbc.OracleTypes.STRUCT, "RECT").
    Then, execute your procedure using cStmt.execute();
    Retrieve your OUT parameter using oracle.sql.STRUCT struct = (oracle.sql.STRUCT)cStmt.getObject(2).
    Once you've done that, to get the values of the attributes of all of your STRUCT objects, you need their descriptors and their metadata.

  • NHRT and illegal memory parameter

    Hi
    I'm trying to make a set of NHRTs by calling them from the Main class as shown below:-
    PeriodicThread Class:-
    package task_set;
    import javax.realtime.*;
    import java.io.StringWriter;
    public class PeriodicThread extends NoHeapRealtimeThread {
    // The following parameters and constructor for Priority_based scheduler
    int p; //Priority relative to min priority
    PriorityScheduler ps;
    ReleaseParameters rp;
    StringWriter st;
    Clock cl;
    PeriodicThread(int p_in,ReleaseParameters rp_in,PriorityScheduler ps_in,StringWriter st_in,Clock cl_in){
    super(new PriorityParameters(ps_in.getMinPriority()+p_in),rp_in,ImmortalMemory.instance());
    p=p_in;
    rp=rp_in;
    ps=ps_in;
    st=st_in;
    cl=cl_in;
    public void run(){
    try{
    st.write("ID:"+this.getId()+",Priority:"+this.getPriority()+",Cost"+this.getProcessingGroupParameters().getCost()+",R_Deadline:"+this.getProcessingGroupParameters().getDeadline()+",Period:"+this.getProcessingGroupParameters().getPeriod()+",Start:"+this.getProcessingGroupParameters().getStart()+",Now:"+cl.getTime());
    }catch(Exception e){
    e.printStackTrace();
    Main Class
    package task_set;
    import javax.realtime.*;
    import java.io.StringWriter;
    public class Main {
    * @param args the command line arguments
    public static void main(String[] args) {
    // TODO code application logic here
    int pri=4; //priority
    Clock cl=Clock.getRealtimeClock();
    PriorityScheduler ps=(PriorityScheduler)Scheduler.getDefaultScheduler();
    PeriodicParameters rp=new PeriodicParameters(cl.getTime().add(1000, 0),new RelativeTime(10,0),new RelativeTime(5,0),new RelativeTime(10,0),null,null);
    StringWriter sw= new StringWriter(5000);
    //MemoryArea ma=RealtimeThread.getCurrentMemoryArea();
    try{
    PeriodicThread pt1=new PeriodicThread(pri,rp,ps,sw,cl);
    pt1.start();
    }catch(Exception e){
    e.printStackTrace();
    Program compiles without errors, but when run gives the following error:-
    java.lang.IllegalArgumentException: Illegal Memory Area Passed or argument allocated in heap
    at javax.realtime.NoHeapRealtimeThread.<init>(NoHeapRealtimeThread.java:219)
    at javax.realtime.NoHeapRealtimeThread.<init>(NoHeapRealtimeThread.java:196)
    at javax.realtime.NoHeapRealtimeThread.<init>(NoHeapRealtimeThread.java:130)
    at task_set.PeriodicThread.<init>(PeriodicThread.java:23)
    at task_set.Main.main(Main.java:27)
    I tried to look for on line code examples for NHRTs to see what the wrong with "memory" parameter is but there are few examples and do not mention more information about memory parameters.
    Please help.

    From the command-line (-Dehcache.monitor.enabled=True) you are using some form of caching.
    The out-of-memory occured as the JVM was unable the allocate an object: C Heap : 1 memory allocations have failed
    Could you check how the live data set is going (or the memory leak detector)
    Some concerns with regard to tune a JVM that runs a cache can be found here: http://middlewaremagic.com/weblogic/?p=7083
    Note that the example given discusses Coherence, but can be adopted for another caching mechanism as well.

  • How to design constructor with variable parameters?

    I'm working on a "project" where I need to make a class "book" that can store information about a book. It's name, isbn, stock, etc... What is throwing me off a little bit is the author. I'm allowed to enter up to 4 authors per book object. I'm coming at the problem with the assumption, that I should be able to load this author data within the constructor. Questions is how. At first I thought I'd make 4 different constructors, each with a different number of author parameters. Simple enough but it seems unnecessarily messy. Then I thought I'd make a variable length parameter array. e.g book( String ... author ). But what if someone wants to enter more than 4 authors or none at all?
    QUESTION:
    Is there a way I can set a minimum and maximum of inputs for variable length paramters?
    Vectors seem like they could be useful here instead of arrays. But again there is that problem of controlling constructor parameters.

    Then I thought I'd make a variable length parameter array. e.g book( String ... author ). (Otherstuff, String author, String ... otherAuthors)
    Is there a way I can set a minimum and maximum of inputs for variable length paramters?Validate it in the code itself
    Or create another class specifically for Authors
    No matter what you do you will still need validation code, for example what if the author is null? Or empty?
         class Authors
                public String Author1;
                public String Author2;
                public String Author3;
                public String Author4;
                public Authors(String auth)
                public Authors(String auth1, String auth2)
           }

  • Help on parameterized constructor please

    So i have a menuing system. I create each window in a new class, but the problem is to detect which button is pressed in one of the provider classes by the driver class. I want the driver class to detect i have pressed for instance "list" to run the list class. Here i thought parameterized constructors would work best to get the variables across, but for some reason it is not working. Here is the code: (The gui works and detects the button is pushed etc.)
    Provider class:
    import java.awt.event.*;
    import javax.swing.*;
    import java.util.*;
    import java.awt.event.*;
    import java.awt.*;
    public class MainMenu implements ActionListener
         public String choice = "";
         public MainMenu(String c)
              choice = c;
         JFrame jf = new JFrame("Main Menu");
         Toolkit tk = Toolkit.getDefaultToolkit ();
        int x = (int) tk.getScreenSize ().getWidth ();
        int y = (int) tk.getScreenSize ().getHeight ();
        ImageIcon ev = new ImageIcon("event.png");
        ImageIcon lb = new ImageIcon("list.png");
        ImageIcon cv = new ImageIcon("vote.png");
        ImageIcon bb = new ImageIcon("bio.png");
        Font f1 = new Font ("Tahoma", Font.BOLD, 25);
        Font f2 = new Font ("Chiller", Font.BOLD, 100);
        JLabel lbl = new JLabel("MAIN MENU");
        JLabel space = new JLabel ("");
         JButton jb1 = new JButton("Events", ev);
         JButton jb2 = new JButton("Leader Board", lb);
         JButton jb3 = new JButton("Cast Vote", cv);
         JButton jb4 = new JButton("Band Biographies", bb);
         GridLayout grid = new GridLayout(10,10,1,1);
         JPanel jp0 = new JPanel();
         JPanel jp1 = new JPanel();
         JPanel jp2 = new JPanel();
         JPanel jp3 = new JPanel();
         JPanel jp4 = new JPanel();
         public MainMenu()
             lbl.setFont(f2);
             jf.setBounds(0,0, x,y);
              jf.setVisible(true);
              jf.setResizable(false);
              jf.setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE);
              jb1.addActionListener(this);
              jb2.addActionListener(this);
              jb3.addActionListener(this);
              jb4.addActionListener(this);
              jb1.setFont(f1);
              jb2.setFont(f1);
              jb3.setFont(f1);
              jb4.setFont(f1);
              jp0.add(lbl);
             jp1.add(jb1);
             jp2.add(jb2);
             jp3.add(jb3);
             jp4.add(jb4);
             jf.setLayout(grid);
             jf.add(space);
             jf.add(space);
             jf.add(jp0);
             jf.add(space);
             jf.add(jp1);
             jf.add(jp2);
             jf.add(jp3);
             jf.add(jp4);
             jf.repaint();
        public void actionPerformed (ActionEvent e)
             if (e.getSource () == jb1)
                  choice = "events";
                  System.out.println(choice);//Just to test whether the buttons work...
             else if (e.getSource () == jb2)
                  choice = "list";
                  System.out.println(choice);
             else if (e.getSource () == jb3)
                  choice = "vote";
                  System.out.println(choice);
             else if (e.getSource () == jb4)
                  choice = "bio";
                  System.out.println(choice);
        public String getChoice()
             return choice;
    }and here is the driver class which doesnt read the change in the choice variable:
    public class PAT
        public static void main(String[] args) //implements ActionListener
              String choice = "";
              MainMenu mm = new MainMenu(choice);
              new MainMenu();
              while (choice.equals(""))
              if (choice.equals("list"))
                   System.out.println("Parameterized constructor works");
    }Any help or advice would be greatly appreciated. Thanks in advance.

    Here is exactly what im trying to do. Im making a menu system. It consists of several windows. For instance main menu has 3 buttons. each button takes you to a new window. Each new window has a back button to return to the main menu. and then the new windows might also have buttons to go to another new window and will have buttons too.
    Im making each window (menu window) in a new class. I want to be able to call these classes (windows) as desired. so all the loops and so on to run the different windows at the right times should be in the main class. makes it easier, as ill be jumping around between programs much less. i just want my parameterized constructors to work, because i believe this will be the easiest way. to have variables, that if changed in one of the provider classes, they will change in the driver class too. this way all i do is change a variable when a button i clicked in the provider classes. then the driver class does a certain action according to the value of the variable read from the provider classes. for instance my choice variable (which is now an int) detects what button is clicked. then my driver class runs the next window based on the value of choice which it recieved from the other classes.
    I hope it makes sense.
    Thank you for the quick replies.

  • Invoking super constructor of a parameterized class

    Hi all,
    I am getting a rather surprising warning messge
    "Type safety: The constructor Super(Class) belongs to the raw type Super. References to the generic type Super<T> should be parameterized."
    Of course, if the super constructor accepts Class instead of Class<T>, then everything is OK.
    I've tried all sorts of things to get rid of this, all to no effect. What to do?
    public class Super<T> {
         public Super(Class<T> c) {
    public class Sub extends Super {
         public Sub(Class<Object> c) {
              // warns on the following line:
              super(c); 
    }Thanks for any help!
    Marc

    Or, if Sub is to be generic:
    public class Sub<T> extends Super<T> {
      public Sub(Class<T> c) {
    }

  • Parameterized constructor in servlets

    why can't we use parameterized constructor in servlets?
    please describe it briefly?

    Why should you use parametrized constructor with servlet? If you want to pass any parameter then use <init-param> in web.xml. Even if you make parameterized constructor, how it would be invoked? Servlet container creates instance of servlet by invoking common constructor.
    So do you intent to rewrote container to invoke parameterized constructor?
    Please refer servlet documentation for more information on servlets and it would help you.

  • Flash CS5 - code hinting doesn't show custom class constructor parameters

    Hi I've got other strange problem my code hinting works almost fine the  problem is that when I create my custom class object code hinting  doesn't show what kind of parameters can be passed to the class  constructor. It shows only "MyClass()", when i call a method like this  class_object.methodName( - parameters show correctly. What can be the  problem?

    I do not work for Adobe, just a fellow forum dweller.
    The example was made quickly because you said this:
    I've tried flash builder but if there is a way to associate code directly from it to symbols on the timeline I haven't been able to find it.
    Now you know how.
    I'm sorry but I don't even have Flash CS6. I still use CS5.5 because I use Flash Builder 4.6 for everything I do. I merely use Flash Pro to generate quick libraries full of goodies and export a SWC to use in Flash Builder.
    I realize it's obvious but you did ensure your preferences had hinting both enabled and the delay set low (or zero)? I can only show you a CS5.5 preference panel, I'm not sure if it's the same. Note one important thing in this photo which is "Cache size". I have mine on 800 files which seems to be fine. If you're pointing toward a HUGE library of classes you may want to increase that number and check completion again.

Maybe you are looking for