Populating application constant values using context namespaces

I have a table like below:
SQL> SELECT * FROM my_constants;
CONSTANT_ID CONSTANT_O CONSTANT_N CONSTANT_V CONSTANT_T CONSTANT_MODULE       SOURCE_ID
      10252 CONSTANT1  CONSTANT1  5000       NUMBER(10) MODULE1                       1
      10253 CONSTANT2  CONSTANT2  5001       NUMBER(10) MODULE2                       1
      10254 CONSTANT1  CONSTANT1  6000       NUMBER(10) MODULE1                       2
      10255 CONSTANT2  CONSTANT2  6001       NUMBER(10) MODULE2                       2I have created a context which uses a procedure load_constants in a package global_constants, say . Right now this package is loading all the rows of CONSTANT_NAME and CONSTANT_VALUE using a logon trigger. I also have a get_val procedure in the package which returns the value of a constant when I query like following:
select global_constants.get_val('CONSTANT1') from dual;All is working fine till here. But, if you observe, the constant names are common in my table, but they are seggregated by SOURCE_ID. Now, my question is that, is there a way I can have the constant names common, but can retrieve the values based on the SOURCE_ID and CONSTANT_NAME combination?
Since DBMS_SESSION.SET_CONTEXT accepts only three parameters (i.e, It only allows us to populate a max 2D array values), I am unable to set the combination. I already can think of a way of handling it a crude way by appending the combination and loading it. But, in the current situation, it is not possible to do so. Also, please note that the logon trigger does neither know which source has created this session nor which source values it should populate, so is populating everything.
Any Ideas?

SQL> select * from my_constants;
CONSTANT_ID CONSTANT_O CONSTANT_N CONSTANT_V CONSTANT_T CONSTANT_MODULE       SOURCE_ID
      10252 CONSTANT1  CONSTANT1  5000       NUMBER(10) MODULE1                       1
      10253 CONSTANT2  CONSTANT2  5001       NUMBER(10) MODULE2                       1
      10254 CONSTANT1  CONSTANT1  6000       NUMBER(10) MODULE1                       2
      10255 CONSTANT2  CONSTANT2  6001       NUMBER(10) MODULE2                       2
SQL> CREATE OR REPLACE PACKAGE my_constant_info
  2  IS
  3     PROCEDURE load_context;
  4 
  5     FUNCTION get_val (in_constant_name IN VARCHAR2)
  6        RETURN VARCHAR2;
  7  END my_constant_info;
  8  /
Package created.
SQL> CREATE OR REPLACE PACKAGE BODY my_constant_info
  2  IS
  3     PROCEDURE load_context
  4     IS
  5        l_names    DBMS_SQL.varchar2s;
  6        l_values   DBMS_SQL.varchar2s;
  7 
  8        CURSOR con_cur
  9        IS
10           SELECT   constant_name, constant_value
11               FROM my_constants
12           ORDER BY constant_id DESC;
13 
14        l_count    NUMBER (8);
15        l_name     VARCHAR2 (100);
16        l_val      VARCHAR2 (400);
17     BEGIN
18        FOR i IN con_cur
19        LOOP
20           l_count               := con_cur%ROWCOUNT;
21           l_names (l_count)     := i.constant_name;
22           l_values (l_count)    := i.constant_value;
23           DBMS_SESSION.set_context ('my_context', l_names (l_count),
24                                     l_values (l_count));
25        END LOOP;
26     EXCEPTION
27        WHEN OTHERS
28        THEN
29           DBMS_OUTPUT.put_line (l_count || ', ' || l_name || ': ' || l_val);
30           RAISE;
31     END load_context;
32 
33   FUNCTION get_val (in_constant_name IN VARCHAR2)
34        RETURN VARCHAR2
35     AS
36        l_return_val   VARCHAR2 (400);
37        l_null_val     EXCEPTION;
38     BEGIN
39        l_return_val    := SYS_CONTEXT ('my_context', in_constant_name);
40 
41         IF l_return_val IS NULL
42        THEN
43           RAISE l_null_val;
44        ELSE
45           RETURN l_return_val;
46        END IF;
47     EXCEPTION
48        WHEN l_null_val
49        THEN
50           raise_application_error (-20011,
51                                       'Requested Constant '''
52                                    || in_constant_name
53                                    || ''' Returned Null.');
54     END get_val;
55  END my_constant_info;
56  /
Package body created.
SQL> CREATE CONTEXT my_context USING my_constant_info;
Context created.
SQL>
SQL> CREATE OR REPLACE TRIGGER my_constant_logon
  2     AFTER LOGON ON DATABASE
  3  BEGIN
  4     my_constant_info.load_context;
  5  EXCEPTION
  6     WHEN OTHERS
  7     THEN
  8        RAISE;
  9  END;
10  /
Trigger created.
SQL> BEGIN
  2     my_constant_info.load_context;
  3  END;
  4  /
PL/SQL procedure successfully completed.
SQL>
SQL> select my_constant_info.get_val('CONSTANT1') from dual;
MY_CONSTANT_INFO.GET_VAL('CONSTANT1')
5000
SQL> I am able to get the value 5000. But, if you look at the data back, there are two rows with CONSTANT1 one for source_id 1 and another for 2. The values of the CONSTANT1 changes according to the source_id. I would like to implement such a solution that it will have to output the values based on the combination of CONSTANT_NAME and SOURCE_ID
One way (not practical for me) is as follows:
SQL> CREATE OR REPLACE PACKAGE BODY my_constant_info
  2  IS
  3     PROCEDURE load_context
  4     IS
  5        l_names    DBMS_SQL.varchar2s;
  6        l_values   DBMS_SQL.varchar2s;
  7 
  8        CURSOR con_cur
  9        IS
10           SELECT   constant_name ||'-'|| source_id constant_name, constant_value
11               FROM my_constants
12           ORDER BY constant_id DESC;
13 
14        l_count    NUMBER (8);
15        l_name     VARCHAR2 (100);
16        l_val      VARCHAR2 (400);
17     BEGIN
18        FOR i IN con_cur
19        LOOP
20           l_count               := con_cur%ROWCOUNT;
21           l_names (l_count)     := i.constant_name;
22           l_values (l_count)    := i.constant_value;
23           DBMS_SESSION.set_context ('my_context', l_names (l_count),
24                                     l_values (l_count));
25        END LOOP;
26     EXCEPTION
27        WHEN OTHERS
28        THEN
29           DBMS_OUTPUT.put_line (l_count || ', ' || l_name || ': ' || l_val);
30           RAISE;
31     END load_context;
32 
33   FUNCTION get_val (in_constant_name IN VARCHAR2)
34        RETURN VARCHAR2
35     AS
36        l_return_val   VARCHAR2 (400);
37        l_null_val     EXCEPTION;
38     BEGIN
39        l_return_val    := SYS_CONTEXT ('my_context', in_constant_name);
40 
41         IF l_return_val IS NULL
42        THEN
43           RAISE l_null_val;
44        ELSE
45           RETURN l_return_val;
46        END IF;
47     EXCEPTION
48        WHEN l_null_val
49        THEN
50           raise_application_error (-20011,
51                                       'Requested Constant '''
52                                    || in_constant_name
53                                    || ''' Returned Null.');
54     END get_val;
55  END my_constant_info;
56  /
Package body created.
SQL> BEGIN
  2     my_constant_info.load_context;
  3  END;
  4  /
PL/SQL procedure successfully completed.
SQL> select my_constant_info.get_val('CONSTANT1-1') from dual;
MY_CONSTANT_INFO.GET_VAL('CONSTANT1-1')
5000
SQL> select my_constant_info.get_val('CONSTANT1-2') from dual;
MY_CONSTANT_INFO.GET_VAL('CONSTANT1-2')
6000
SQL> I would like to know any other elegant way of implementing the same, where in if I say something like
select my_constant_info.get_val('CONSTANT1', p_source_id) from dual;
or
v_cons_val := my_constant_info.get_val('CONSTANT1', p_source_id);
** where p_source_id is a value passed to a procedure and v_cons_val is a variable, say.Please let me know if you need any further infomation.

Similar Messages

  • Using VM level application constant to set the attributes on the interview screen

    Hi All,
    We have a Performed By as one of the interview question which should be defaulted with the user id of the person who launched the OPA session (through web determinations).
    There is a user-id application constant which is available at the VM layer. Is there a way to set the Performed By question on the interview screen with this user-id by modifying the VM templates?
    Please help.
    Thanks,
    KK

    I tried with that code, its giving compile error for this: Can you please let me know what I am missing here:
    PreSeedValues.java:44: isUnknown(com.oracle.determinations.engine.EntityInstance
    ) in com.oracle.determinations.engine.Attribute cannot be applied to ()
                    boolean userIdKnown = (! performedBy.isUnknown()) && (! performe
    dBy.isUncertain() );
    Because an attribute exists for an entity, it can have different values across different instances, so, when you try to get the value (or check its know/unknown state) you need to pass in the entity instance. In you case the global entity instance: performedBy.isUnknown(ruleSessionGlobal) and performedBy.isUncertain(ruleSessionGlobal)
    Also, one more thing, we have around 50 different screens and each screen has this performed by attribute with different name. Now to set this in code, it would not be a good idea to write 50 lines for different performed by attributes. Can we have something like getting the screen name for the current screen in user context and user that as a prefix for the attrubute name. e.g. RA0084_Sheet_Performed_By in this RA0084_Sheet will be the interview screen name.
    It sounds like you want to set the user id when each screen is submitted. The OnInvestigationStartedEvent will only fire once, when the investigation starts. If you want to set an attribute when a screen is submitted, you probably want to use something like a OnValidateScreenEventHandler which is fired when a screen is submitted and has the screen details in the event.
    See Events and Event Handlers in Oracle Policy Automation Developer's Guide

  • Custom: use constant value in relationship between objects?

    I have two related classes:
    * Class A uses application identity, and has multiple PK fields, PK1 and
    PK2.
    * Class B has a 1-many relationship with class A. However, class B's
    database table only has a column that relates to Class A's PK2 column.
    (the PK1 value is a constant) for all Class B objects).
    I have no idea how to express this relationship via kodo. Can anyone
    assist?

    What I've chosen to do is add a new DB column to my table which has a
    constant value (ie: is the same for every row). Then I can join with it.
    I'd request this simple feature to be added in a future release: the
    ability to specify a literarl constant value as part of the join
    criteria in the metadata. It could be very easily added: instead of
    specifying a column containing the join value, you could put the literal
    into the .jdo file.
    thanks.
    Patrick Linskey wrote:
    You could put together a custom field mapping that performed the join
    like you described if you really wanted to. Bear in mind, however, that
    the field mapping APIs are subject to change etc. etc. etc.
    -Patrick
    On Tue, 20 May 2003 22:25:16 -0400, David Michaels wrote:
    Thanks for the quick reply, as usual Abe.
    In this case, I will link to the full PK of the related object, just one
    of the components of that PK is a constant. There's no place to
    override the SQL used for these sort of joins?
    Perhaps I can do this with a view too.
    Abe White wrote:
    It's not possible to create a Kodo relation that doesn't actually link
    to the (full) primary key of the related object. Note that in general,
    that kind of database design is not a good idea, because there's no
    guarantee you're linking to a unique object.
    You can use a Kodo query to get the related objects; you could hide the
    query behind your getter method.

  • Use of Class Vs Interface for defining application constants

    I want to use some constants through out the application. For that I found two ways to do that as given below
    1. We can define constants in a class as
    public class ConstantClass {
    public static final String applConstant = "Some Constant";
    and use it ConstantClass.applConstant whereever needed
    Or
    2. We can define an interface as
    public interface IConstantInterface {
    String applConstant = "Some Constant";
    and use it IConstantInterface.applConstant
    Can you pls explain which is the best method to be used in the application and why?
    Thanks in advance.

    Hmmm - that would imply that if I have a reference a
    static final variable in a 3rd party class, then
    compile my class to a .class file, then the 3rd party
    changes their class file, that my .class file would
    not contain the correct values.Yep, that is what would happen
    I doubt this. I haven't read the compiler specs, but
    my assumption would be that compile time optimizations
    such as this only apply to constants within a single
    .class file.You don't need the compiler specs, you just need a compiler.
    Compile the two classes below, and run Main. Your output should look like:
    3
    Hello
    5
    Hooky
    Then delete the Constants.class file and run Main again and see what happens.
    == Constants.java ==
    public class Constants {
    public static final int INT_CONSTANT = 3;
    public static final String STRING_CONSTANT = "Hello";
    public static int i = 5;
    public static String s = "Hooky";
    == End Constants.java ==
    == Main.java ==
    public class Main {
    public static void main(String[] args) {
    System.out.println(Constants.INT_CONSTANT);
    System.out.println(Constants.STRING_CONSTANT);
    System.out.println(Constants.i);
    System.out.println(Constants.s);
    == End Main.java ==
    In case you are wondering:
    java version "1.4.1_02"
    OS: Solaris 8
    Arch: Sparc
    I get the same thing on windows with 1.4 and 1.3
    and on FreeBSD with diablo jdk 1.3

  • Use context to pass value between JPF and Java Control

    hi,
    Can we use context to pass value between JPF and Java Control? It works if i m using InitialContext in the same machine but i dun think it will works if i put Web server and application server in different machine. Anyone have an idea how to do it?
    I also want to get the method name in the onAcquire callback method. Anyone knows how to do this?
    thks
    ?:|

    Hi.
    Yoy can the next options for make this:
    1. Pass your values in http request.
    example: http://localhost/index.jsp?var1=value1&var2=value2&var3....
    2. You can use a no visible frame (of height or width 0) and keep your variables and values there using Javascript, but of this form, single you will be able to check the values in the part client, not in the server. Of this form, the values of vars are not visible from the user in the navigation bar.
    Greeting.

  • How to read application item's value using  javascript

    Is there any way to read value of application item using javascript?
    Thanks

    Javascript can access the objects rendered for the page you are calling. This is why the $v function will do the work if calling it for a page item. However an application item isn't rendered on the page - the session state of it is only stored in the table. This is why you need to do it the way I described. You could do a workarround and create a hidden item on your page and compute the value of it using the application item value. Then you would be able to get the value of your application item using $v function.
    Denes Kubicek
    http://deneskubicek.blogspot.com/
    http://www.opal-consulting.de/training
    http://apex.oracle.com/pls/otn/f?p=31517:1
    ------------------------------------------------------------------------------

  • Adding new constant value to an 'enum' used in a field causes an exception

    We are using the DPL. I added a new constant to an enum that is used as a field on an entity called Booking (this field is not a key). This seems to cause an exception during onForeignKeyDelete when we delete an object from a related entity. The constraint is a "NULLIFY" on a "MANY_TO_ONE" relationship, so the effect should be just to nullify the Booking foreign key, but for some reason the fields are being checked and causing this exception. Shouldn't it be possible to add a new constant value to an enum without having to do some sort of migration? The stack is below. Note that the two types mentioned in the exception message are in fact the same (this is the enum). For the moment we can truncate our database, because we are still in development, but this would present a problem in production.
    IllegalArgumentException: Not a subtype of the field's declared class com.chello.booking.model.BookingStatus: com.chello.booking.model.BookingStatus
    at com.sleepycat.persist.impl.RawAbstractInput.checkRawType(RawAbstractInput.java:142)
    at com.sleepycat.persist.impl.RecordOutput.writeObject(RecordOutput.java:75)
    at com.sleepycat.persist.impl.RawAccessor.writeField(RawAccessor.java:232)
    at com.sleepycat.persist.impl.RawAccessor.writeNonKeyFields(RawAccessor.java:148)
    at com.sleepycat.persist.impl.ComplexFormat.writeObject(ComplexFormat.java:528)
    at com.sleepycat.persist.impl.PersistEntityBinding.writeEntity(PersistEntityBinding.java:143)
    at com.sleepycat.persist.impl.PersistKeyCreator.nullifyForeignKeyInternal(PersistKeyCreator.java:170)
    at com.sleepycat.persist.impl.PersistKeyCreator.nullifyForeignKey(PersistKeyCreator.java:137)
    at com.sleepycat.je.SecondaryDatabase.onForeignKeyDelete(SecondaryDatabase.java:1082)
    at com.sleepycat.je.ForeignKeyTrigger.databaseUpdated(ForeignKeyTrigger.java:37)
    at com.sleepycat.je.Database.notifyTriggers(Database.java:2016)
    at com.sleepycat.je.Database.deleteInternal(Database.java:800)
    at com.sleepycat.je.Database.delete(Database.java:714)
    at com.sleepycat.persist.BasicIndex.delete(BasicIndex.java:133)
    at com.sleepycat.persist.PrimaryIndex.delete(PrimaryIndex.java:206)
    at com.sleepycat.persist.BasicIndex.delete(BasicIndex.java:124)
    at com.sleepycat.persist.PrimaryIndex.delete(PrimaryIndex.java:206)
    Kind regards
    James Brook

    James,
    I've started investigating this and at first look it does appear to be a DPL bug. Over the next few days I'll look more deeply and report back here with what I find. If it is indeed a bug, we'll fix this for the next JE 4.0.x release and I'll make the fix available to you.
    You are correct that adding enum values is allowed without a conversion of any kind. The only change you should have to make, other than adding the enum value, is to bump the version of the containing entity in the @Entity annotation. I'm suspect you've already done that, but if you hadn't, it wouldn't cause the problem you're seeing.
    We have tested the addition of enum values, but not in combination with foreign key deletion and the NULLIFY constraint, I'm afraid.
    If I'm correct about it, the bug is specific to adding enum values and deleting a secondary key with the NULLIFY constraint, prior to re-writing the entity in some other way. So if the entity is updated (written) before the secondary key is deleted, then the problem should not occur. Therefore, one workaround is to call EntityStore.evolve after adding the enum value, and before using the store in other ways.
    Thanks for reporting this, and I hope this is not blocking your development.
    --mark                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Populating a combo box using values in a table

    I am trying to populate a drop down box with values from a table. I have got so far.
    The combo box is populated however the values in the box are blank.
    Can some suggest the necessary modifications?
    $query="select distinct(house_type) from tbl_accommodation";
    $stmt = ociparse($conn, $query);
    ociexecute($stmt);
    echo '<select name="house_type">';
    echo '<option value = "-1">Select:</option>';
    while($row=ocifetch($stmt)) {
         echo '<option>' . $row['house_type'] . '</option>';
         echo '</select>';
    Thanks

    The ocifetch() function needs ociresult() to get the data. See
    http://us.php.net/manual/en/function.oci-result.php
    You might want to use oci_fetch_assoc() instead.
    while($row=oci_fetch_assoc($stmt)) {
      echo '<option>' . $row['HOUSE_TYPE'] . '</option>';
    }For associative arrays, use the column name in upper case.
    NB Oci_fetch_assoc() is a PHP 5 function. If you don't have it, then
    you are using PHP 4 which has a much older version of the OCI8
    extension. I'd recommend upgrading PHP, or just replacing the old
    OCI8 with a newer one. See other recent threads about how to do this.

  • Populating Constant value to a column while inserting new lines to ALV Grid

    Hi all,
        I need to know how to populate a column in an ALV grid with a constant value , whenever a new line is inserted in the ALV.
    Regards,
    Vijayakumar

    Hi Arun,
    g_t_alv is my Internal table. I am inseritng a button in the field name ICON.Now all my records in the ALV will contain a button in the field ICON. But when i create a new line in the ALV the field ICON is containing an empty space.
    loop at g_t_alv into g_r_alv.
          ls_edit-fieldname = 'ICON'.
          ls_edit-style     = cl_gui_alv_grid=>mc_style_button.
          INSERT ls_edit INTO TABLE lt_edit.
        INSERT LINES OF lt_edit INTO TABLE g_r_alv-handle_style.
        MODIFY g_t_alv FROM g_r_alv.
    endloop.

  • Create xml file with values from context

    Hi experts!
    I am trying to implement a WD application that will have some input fields, the value of those input fields will be used to create an xml file with a certain format and then sent to a certain application.
    Apart from this i want to read an xml file back from the application and then fill some other context nodes with values from the xml file.
    Is there any standard used code to do this??
    If not how can i do this???
    Thanx in advance!!!
    P.S. Points will be rewarded to all usefull answers.
    Edited by: Armin Reichert on Jun 30, 2008 6:12 PM
    Please stop this P.S. nonsense!

    Hi,
    you need to create three util class for that:-
    XMLHandler
    XMLParser
    XMLBuilder
    for example in my XML two tag item will be there e.g. Title and Organizer,and from ur WebDynpro view you need to pass value for the XML tag.
    And u need to call buildXML()function of builder class to generate XML, in that i have passed bean object to get the values of tags. you need to set the value in bean from the view ui context.
    Code for XMLBuilder:-
    Created on Apr 4, 2006
    Author-Anish
    This class is to created for having function for to build XML
    and to get EncodedXML
      and to get formated date
    package com.idb.events.util;
    import java.text.SimpleDateFormat;
    import java.util.Date;
    import com.idb.events.Event;
    public class XMLBuilder {
    This attribute represents the XML version
         private static final double VERSION_NUMBER = 1.0;
    This attribute represents the encoding
         private static final String ENCODING_TYPE = "UTF-16";
         /*Begin of Function to buildXML
    return: String
    input: Event
         public String buildXML(Event event) {
              StringBuffer xmlBuilder = new StringBuffer("<?xml version=\"");
              xmlBuilder.append(VERSION_NUMBER);
              xmlBuilder.append("\" encoding=\"");
              xmlBuilder.append(ENCODING_TYPE);
              xmlBuilder.append("\" ?>");
              xmlBuilder.append("<event>");
              xmlBuilder.append(getEncodedXML(event.getTitle(), "title"));
              xmlBuilder.append(getEncodedXML(event.getOrganizer(), "organizer"));
              xmlBuilder.append("</event>");
              return xmlBuilder.toString();
         /End of Function to buildXML/
         /*Begin of Function to get EncodedXML
    return: String
    input: String,String
         public String getEncodedXML(String xmlString, String tag) {
              StringBuffer begin = new StringBuffer("");
              if ((tag != null) || (!tag.equalsIgnoreCase("null"))) {
                   begin.append("<").append(tag).append(">");
                   begin.append("<![CDATA[");
                   begin.append(xmlString).append("]]>").append("</").append(
                        tag).append(
                        ">");
              return begin.toString();
         /End of Function to get EncodedXML/
         /*Begin of Function to get formated date
    return: String
    input: Date
         private final String formatDate(Date inputDateStr) {
              String date;
              try {
                   SimpleDateFormat simpleDateFormat =
                        new SimpleDateFormat("yyyy-MM-dd");
                   date = simpleDateFormat.format(inputDateStr);
              } catch (Exception e) {
                   return "";
              return date;
         /End of Function to get formated date/
    Code for XMLParser:-
    Created on Apr 12, 2006
    Author-Anish
    This is a parser class
    package com.idb.events.util;
    import java.io.ByteArrayInputStream;
    import java.io.IOException;
    import javax.xml.parsers.ParserConfigurationException;
    import javax.xml.parsers.SAXParser;
    import javax.xml.parsers.SAXParserFactory;
    import org.xml.sax.InputSource;
    import org.xml.sax.SAXException;
    import org.xml.sax.XMLReader;
    import com.idb.events.Event;
    import com.sap.tc.webdynpro.progmodel.api.IWDMessageManager;
    public class XMLParser {
    Enables namespace functionality in parser
         private final boolean isNameSpaceAware = true;
    Enables validation in parser
         private final boolean isValidating = true;
    The SAX parser used to parse the xml
         private SAXParser parser;
    The XML reader used by the SAX parser
         private XMLReader reader;
    This method creates the parser to parse the user details xml.
         private void createParser()
              throws SAXException, ParserConfigurationException {
              // Create a JAXP SAXParserFactory and configure it
              SAXParserFactory saxFactory = SAXParserFactory.newInstance();
              saxFactory.setNamespaceAware(isNameSpaceAware);
              saxFactory.setValidating(isValidating);
              // Create a JAXP SAXParser
              parser = saxFactory.newSAXParser();
              // Get the encapsulated SAX XMLReader
              reader = parser.getXMLReader();
              // Set the ErrorHandler
    This method is used to collect the user details.
         public Event getEvent(
              String newsXML,
              XMLHandler xmlHandler,
              IWDMessageManager mgr)
              throws SAXException, ParserConfigurationException, IOException {
              //create the parser, if not already done
              if (parser == null) {
                   this.createParser();
              //set the parser handler to extract the
              reader.setErrorHandler(xmlHandler);
              reader.setContentHandler(xmlHandler);
              InputSource source =
                   new InputSource(new ByteArrayInputStream(newsXML.getBytes()));
              reader.parse(source);
              //return the results of the parse           
              return xmlHandler.getEvent(mgr);
    Code for XMLHandler:-
    Created on Apr 12, 2006
    Author-Anish
    This is a parser class
    package com.idb.events.util;
    import java.io.ByteArrayInputStream;
    import java.io.IOException;
    import javax.xml.parsers.ParserConfigurationException;
    import javax.xml.parsers.SAXParser;
    import javax.xml.parsers.SAXParserFactory;
    import org.xml.sax.InputSource;
    import org.xml.sax.SAXException;
    import org.xml.sax.XMLReader;
    import com.idb.events.Event;
    Created on Apr 12, 2006
    Author-Anish
    *This handler class is created to have constant value for variables and function for get events,
        character values for bean variable,
        parsing thr date ......etc
    package com.idb.events.util;
    import java.sql.Timestamp;
    import java.text.SimpleDateFormat;
    import java.util.Date;
    import java.util.Locale;
    import org.xml.sax.Attributes;
    import org.xml.sax.SAXException;
    import org.xml.sax.SAXParseException;
    import org.xml.sax.helpers.DefaultHandler;
    import java.util.*;
    import com.idb.events.Event;
    import com.sap.tc.webdynpro.progmodel.api.IWDMessageManager;
    public class XMLHandler extends DefaultHandler {
         private static final String TITLE = "title";
         private static final String ORGANIZER = "organizer";
         IWDMessageManager manager;
         private Event events;
         private String tagName;
         public void setManager(IWDMessageManager mgr) {
              manager = mgr;
    This function is created to get events
         public Event getEvent(IWDMessageManager mgr) {
              manager = mgr;
              return this.events;
    This function is created to get character for setting values through event's bean setter method
         public void characters(char[] charArray, int startVal, int length)
              throws SAXException {
              String tagValue = new String(charArray, startVal, length);
              if (TITLE.equals(this.tagName)) {
                   this.events.setTitle(tagValue);
              if (ORGANIZER.equals(this.tagName)) {
                   String orgName = tagValue;
                   try {
                        orgName = getOrgName(orgName);
                   } catch (Exception ex) {
                   this.events.setOrganizer(orgName);
    This function is created to parse boolean.
         private final boolean parseBoolean(String inputBooleanStr) {
              boolean b;
              if (inputBooleanStr.equals("true")) {
                   b = true;
              } else {
                   b = false;
              return b;
    This function is used to call the super constructor.
         public void endElement(String uri, String localName, String qName)
              throws SAXException {
              super.endElement(uri, localName, qName);
         /* (non-Javadoc)
    @see org.xml.sax.ErrorHandler#fatalError(org.xml.sax.SAXParseException)
    This function is used to call the super constructor.
         public void fatalError(SAXParseException e) throws SAXException {
              super.fatalError(e);
    This function is created to set the elements base on the tag name.
         public void startElement(
              String uri,
              String localName,
              String qName,
              Attributes attributes)
              throws SAXException {
              this.tagName = localName;
              if (ROOT.equals(tagName)) {
                   this.events = new Event();
         public static void main(String a[]) {
              String cntry = "Nigeria";
              XMLHandler xml = new XMLHandler();
              ArrayList engList = new ArrayList();
              engList = xml.getCountries();
              ArrayList arList = xml.getArabicCountries();
              int engIndex = engList.indexOf(cntry);
              System.out.println("engIndex  :: " + engIndex);
              String arCntryName = (String) arList.get(engIndex);
              System.out.println(
                   ">>>>>>>>>>>>>>>>>>>>" + xml.getArabicCountryName(cntry));
    Hope that may help you.
    If need any help , you are most welcome.
    Regards,
    Deepak

  • How to use portlet:namespace in flex files?

    Hi,
    Iam developing a portlet whose UI is flex. using MXML and action script.
    Portlets require that their UI elements be unique to each portlet, so we use <portlet:namespace> for each ID, vars, functions etc..
    My question is how should i use this tag in my UI?
    Is this the right place to ask this question, if NO, the please direct me to the right forum.
    Thank you,

    application-param tag in weblogic-application.xml may be used to define parameters:
    webapp.encoding.default
    webapp.encoding.usevmdefault
    webapp.getrealpath.accept_context_path
    http://e-docs.bea.com/wls/docs81/programming/app_xml.html#1034632
    "Harshad Nanal" <[email protected]> wrote:
    >
    When we build an ear file , Weblogic-application.xml provides application-param
    tag?
    are they similar to env-entry in ejb-jar.xml.
    Can I use application-param tag to define a configurable params
    say myName and value as "Harshad"
    How do i read it in the application say a simple java class that is included
    in
    a jar inside the ear file.

  • Problem in using context param for storing database connection information

    Hello Friends,
    I am new to struts & jsp.I am developing a project in struts.I have 1 jsp page called editProfile.jsp.On submitting this page it will call 1 action class.The action class in turn will call the Plain old java class where I have written the logic for updating User Profile.
    I have created context-param in web.xml for database connection information like dbURL , dbUserName , dbPassword , jdbcDriver.Now I want to use these connection information in my Business logic(Plain Old Java Class).As we can use context parameter only in jsp & servlets , I am setting the variables of my business logic class with these context param in jsp itself.
    now when I am calling the updateProfile method of Business logic class from Action class it is giving error as all the connection variables which I set in jsp for my business logic class has become null again.
    I am not getting.If once I have set those variables how come they are becoming null again???Please help me.Any Help will be highly appreciated.Thanx in advance.

    This is the code I have written
    web.xml file
    <context-param>
    <param-name>jdbcDriver</param-name>
    <param-value>oracle.jdbc.driver.OracleDriver</param-value>
    </context-param>
    <context-param>
    <param-name>dbUrl</param-name>
    <param-value>jdbc:oracle:thin:@localhost:1521:gd</param-value>
    </context-param>
    <context-param>
    <param-name>dbUserName</param-name>
    <param-value>system</param-value>
    </context-param>
    <context-param>
    <param-name>dbPassword</param-name>
    <param-value>password</param-value>
    </context-param>
    EditProfile.jsp
    <%@page contentType="text/html"%>
    <%@page pageEncoding="UTF-8"%>
    <%@ page import="java.sql.*" %>
    <jsp:useBean id="EditProfile" scope="application"
    class="com.myapp.struts.EditProfile"/>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>Edit My Profile</title>
    </head>
    <body>
    <form action="submitEditProfileForm.do" focus="txt_FirstName" method="post">
    <%
    EditProfile.setjdbcDriver(application.getInitParameter("jdbcDriver"));
    EditProfile.setdbURL(application.getInitParameter("dbURL"));
    EditProfile.setdbUserName(application.getInitParameter("dbUserName"));
    EditProfile.setdbPassword(application.getInitParameter("dbPassword"));
    -----------more code goes here------------
    EditActionProfile.java
    package com.myapp.struts;
    import javax.servlet.jsp.jstl.core.Config;
    import org.apache.struts.action.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.io.*;
    import java.sql.*;
    public class EditProfileAction extends Action {
    public EditProfileAction()
    public ActionForward execute(
    ActionMapping mapping,
    ActionForm form,
    HttpServletRequest request,
    HttpServletResponse response) throws Exception
    try
    if (isCancelled(request))
    return mapping.findForward("mainpage");
    EditProfileForm epf = (EditProfileForm)form;
    EditProfile ep = new EditProfile();
    String temp = ep.updateProfile(epf.getTxt_FirstName(),epf.getTxt_MiddleName() , epf.getTxt_LastName() , epf.getTxt_Address() , epf.getTxt_Email() );
    if(temp.equals("SUCCESS"))
    return mapping.findForward("success");
    else
    return mapping.findForward("failure");
    catch(SQLException e)
    System.out.println("error" + e.getMessage());
    return mapping.findForward("failure");
    EditProfile.java class (My Business Logic Class)
    package com.myapp.struts;
    import java.sql.Connection;
    import java.sql.DriverManager;
    import java.sql.SQLException;
    import java.sql.Statement;
    import java.sql.*;
    public class EditProfile {
    private String dbURL;
    private String dbUserName , jdbcDriver;
    private String dbPassword;
    private Connection con;
    private Statement stmt;
    public EditProfile()
    public void setdbURL(String s )
    this.dbURL = s;
    public void setdbUserName(String s )
    this.dbUserName = s;
    public void setdbPassword(String s )
    this.dbPassword = s;
    public void setjdbcDriver(String s )
    this.jdbcDriver = s;
    public String updateProfile(String firstname , String middlename , String lastname , String address , String email)
    throws SQLException, ClassNotFoundException , java.lang.InstantiationException , IllegalAccessException
    try
    String s1 = new String("update usr set first_name='" + firstname + "' , middle_name='" + middlename + "' , last_name='" + lastname +"' , address='" + address + "' , email_id='" + email + "' where usr_key=1" );
    con = this.init();
    System.out.println("after init");
    stmt = con.createStatement();
    int rslt = stmt.executeUpdate(s1);
    System.out.println("after excute update");
    stmt.close();
    if(rslt>=1)
    return "SUCCESS";
    else
    return "Failure";
    finally
    if (null != con)
    con.close();
    public Connection init() throws SQLException, ClassNotFoundException
    Class.forName(jdbcDriver);
    con = DriverManager.getConnection(dbURL, dbUserName, dbPassword);
    return con;
    public void close(Connection connection) throws SQLException
    if (!connection.isClosed())
    connection.close();
    }

  • Timestamp data type on S[range C on E] constant value-based range windows

    Hello,
    My questiong is about how can we use timestamp value on S[range C on E] constant value-based range windows.
    I have a LotEvent which i should collect and sum lastQty data for last ten minutes of market time (sendDate)
    A normal [range 600] query does not work for me because i would like to use the exact time which data has been generated by the market (sendDate).
    Here is the event;
    public class LotEvent{
         private Double totalQty;
         private float lastQty;
         private String symbol;
         private String messageType;
         private Integer dataInterval;
         private String sendDate;
    send date is always in "MM-dd-yyyy HH:mm:ss" format.
    I have tried to use the following query but this gives an error;
    Invalid statement: "select symbol, sum(lastQty) as lastQty, 10 AS dataInterval
    +from lotInputChannel [range INTERVAL "0 0:0:15.0" DAY TO SECOND on >>sendDate<<]+
    group by symbol"
    Cause: Datatype char is not valid for value based windows
    Action: Use a valid datatype for value based windows>
    Here is the CQL;
    <?xml version="1.0" encoding="UTF-8"?>
    <wlevs:config xmlns:wlevs="http://www.bea.com/ns/wlevs/config/application">
    <processor>
    <name>lotProcTenMin</name>
    <rules>
         <query id="tenMin"> <![CDATA[select symbol, sum(lastQty) as lastQty, 10 AS dataInterval 
                from lotInputChannel [range INTERVAL "0 00:10:00.0" DAY TO SECOND on sendDate]
    group by symbol]]> </query>
    </rules>
    </processor>
    </wlevs:config>
    i have tried this cql after changing the sendDate data type to long which is the time in milliseconds value but it did not work.
    select symbol, sum(lastQty) as lastQty, 10 AS dataInterval
    from lotInputChannel [range INTERVAL "0 00:10:00.0" DAY TO SECOND on to_timestamp(sendDate)]
    group by symbol
    The query above does not work also when sendDate is a String in "MM-dd-yyyy HH:mm:ss" format
    At last i tried the following query with sendDate as time in milliseconds (long) value. It works! but i still would like to know how to use timestamp in S[range C on E] queries
    select symbol, sum(lastQty) as lastQty, 10 AS dataInterval
    from lotInputChannel [range *600000* on sendDate]
    group by symbol
    public class LotEvent{
         private Double totalQty;
         private float lastQty;
         private String symbol;
         private String messageType;
         private Integer dataInterval;
         private long sendDate;
    Could anybody please help me with this issue?
    Edited by: user8830791 on 01-Aug-2011 06:39

    It seems that you should configure the channel "lotInputChannel" as an application timestamped channel.
    You can do that as follows -
    - Have "sendDate" as a long and let its unit be milliseconds
    - Use the following child elements of <channel> for the "lotInputChannel"
    <wlevs:application-timestamped is-total-order="true">
    <wlevs:expression>sendDate*1000*1000</wlevs:expression>
    </wlevs:application-timestamped>
    The multiplication by 10^6 is required since the units need to be converted into nanos
    With this, you could use the query -
    select symbol, sum(lastQty) as lastQty, 10 AS dataInterval
    from lotInputChannel [range 10 minutes]
    group by symbol
    Of course, for the above to work, a requirement is that the value of "sendDate" is non-decreasing.
    That is if e1 is before e2 in the "lotInputChannel" then e1.sendDate <= e2.sendDate
    Edited by: Anand Srinivasan on Aug 2, 2011 6:57 AM

  • Can the Ring Properties/Edit Items/Labels be populated by array values?

    Can the Ring Properties/Edit Items/Labels be populated by array values?
    I'm trying to troubleshoot an existing LabView 7.0 application at our office (this is only the beginning of my nightmare) and I'm finding that there is an array being created out of discrete Elements, which is then being indexed using the Indexed Array function, using a Ring control as the Index input. 
    What I'm seeing is that whoever created this "Appication" seems to require that any new 'elements' that need to be added to the array need to added in AT LEAST two locations (add the element to the array and add a label on the Edit Items tab of the Ring control used to index the array) and there may be more locations I haven't found that also needs the same information.  Since I can't see any way for the array and the ring control to 'compare' the text strings, I'm assuming the array is being indexed using the 'values' from the Edit Items tab.  Ths would allow different text in the Ring dropdown than is actually contained in the text of the array.
    This is contrary to most of the coding practices I've learned, so I'm wondering if I could use the text strings contained in the array itself to populate Item list in the Ring control?
    Later I can create an 'entry form' that would allow new parts to be added by staff that doesn't require knowledge of LabView programming. (The "Users" should NEVER have to see the underlying block diagrams/code to add or edit parts ot test parameter values.)
    Thanks

    In 8.2 you can do this with a property node and the "Strings [ ] Property".  It accepts an array of strings.  Order of strings in array sets the order in the control.  Should work in 7.0 as well.

  • Constant values (public static final String) are not shown??

    This has already been posted and no body answered. Any help is appreciated.
    In web service is it possible to expose the Constants used in the application. Let say for my web service I need to pass value for Operation, possible values for this are (add, delete, update). Is it possible expose these constant values(add, delete, update) visible to client application accesssing the web service.
    Server Side:
    public static final String ADD = "ADDOPP";
    public static final String DELETE = "DELETEOPP";
    public static final String UPDATE = "UPDATEOPP";
    client Side: mywebserviceport.setOperation( mywebservicePort.ADD );
    thanks
    vijay

    Sure, you can use JAX-WS and enums.
    For example on the server:
    @WebService
    public class echo {
    public enum Status {RED, YELLOW, GREEN}
    @WebMethod
    public Status echoStatus(Status status) {
    return status;
    on the client you get.
    @WebService(name = "Echo", wsdlLocation ="..." )
    public interface Echo {
    @WebMethod
    public Status echoStatus(
    @WebParam(name = "arg0", targetNamespace = "")
    Status arg0);
    @XmlEnum
    public enum Status {
    GREEN,
    RED,
    YELLOW;
    public String value() {
    return name();
    public static Status fromValue(String v) {
    return valueOf(v);
    }

Maybe you are looking for

  • Sub contracting Challan closing error

    Dear All,      I am facing problem while doing challan closing in J1IF13 Error message i am getting is Document 0000005560 2010  is not released for accounting. Message no. 8I267 Please help me to solve this issue. Vengatesh.S

  • Why is the game Candy Crush Saga, a free game, not available in the South Africa store?

    Why is the game Candy Crush Saga, a free game, not available in the South Africa store?

  • File Explorer run as administrator

    I have windows 8.1 PRO and I am trying to change the target file under file explorer. It will not allow me ( grwed out) I need to run file explorer as administrator in order to make changes.  I tried all the registry edit  listed on this forum and no

  • Help with custom code in ZTIGather.wsf

    To pick up WMI "version" info to deal with Lenovo computer models I found this code and integrated it by adding these lines to ZTIGather.wsf: ABout line 542: oEnvironment.Item("LenovoModel") = sLenovoModel About line 383         ' Get the Lenovo Mode

  • .wmvs from QT Pro - why is there a 30sec limit?

    I'm trying to make wmvs for Windows people. I've tried outputting the sequence direct from the timeline using QT conversion, and I've tried using Compressor, and also tried opening a self-contained file in QT, and converting that. Each time, I get a