Using Convert to handle NULL values for empty Strings ""

After having had the problem with null values not being returned as nulls and reading some suggestion solution I added a converter to my application.
  <converter>
    <converter-id>NullStringConverter</converter-id>
    <converter-for-class>java.lang.String</converter-for-class>
    <converter-class>com.j2anywhere.addressbookserver.web.NullStringConverter</converter-class>
  </converter>
...I then implemented it as follows:
  public String getAsString(FacesContext context, UIComponent component, Object object)
    System.out.println("Converting to String : "+object);
    if (object == null)
      System.out.println("READING null");
      return "NULL";
    else
      if (((String)object).equals(""))
        System.out.println("READING null (Second Check)");
        return null;       
      else
        return object.toString();
  public Object getAsObject(FacesContext context, UIComponent component, String value)
    System.out.println("Converting to Object: "+value+"-"+value.trim().length());
    if (value.trim().length()==0 || value.equals("NULL"))
      System.out.println("WRITING null");
      return null;
    else
      return value.toUpperCase();
...I can see that it is converting my values, however the object to which the inputText fields are bound are still set to empty strings ""
<h:inputText size="50" value="#{addressBookController.contactDetails.information}" converter="NullStringConverter"/>Also when reading the object values any nulls are already converted to empty strings before ariving at the converter. It seems that there is a default converter handling string values.
How can I resolve this problem as set nulls when the input value is an empty string other then checking every string in my class individually. I would really hate to pollute my object model with empty string tests.
Thanks in advance
Edited by: j2anywhere.com on Oct 19, 2008 9:06 AM

I changed my converter as suggested :
  public Object getAsObject(FacesContext context, UIComponent component, String value)
    if (value == null || value.trim().length() == 0)
      if (component instanceof EditableValueHolder)
        System.out.println("SUBMITTED VALUE SET TO NULL");
        ((EditableValueHolder) component).setSubmittedValue(null);
      else
        System.out.println("COMPONENT :"+component.getClass().getName());
      System.out.println("Converting to Object: " + value + "< to " + null);
      return null;
    System.out.println("Converting to Object: " + value + "< to " + value);
    return value;
  }which produces the following output :
SUBMITTED VALUE SET TO NULL
Converting to Object: < to null
Info : The INFO line however comes from my controller object where I print out the set value :
package com.simple;
import java.util.ArrayList;
import java.util.List;
public class Controller
  private String information;
  /** Creates a new instance of Controller */
  public Controller()
    System.out.println("Createing Controller");
    information = "Constructed";
  public String process()
    System.out.println("Info : "+getInformation());
    return "processed";
  public String reset()
    setInformation("Re-Constructed");
    System.out.println("Info : "+getInformation());
    return "processed";
  public String setNull()
    setInformation(null);
    System.out.println("Info : "+getInformation());
    return "processed";
  public String getInformation()
    return information;
  public void setInformation(String information)
    this.information = information;
}I also changes my JSP / JSF page a little. Here is the updated version
<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@taglib prefix="f" uri="http://java.sun.com/jsf/core"%>
<%@taglib prefix="h" uri="http://java.sun.com/jsf/html"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<%--
    This file is an entry point for JavaServer Faces application.
--%>
<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>JSP Page</title>
  </head>
  <body>
    <f:view>
      <h:form>
        <h:inputText id="value" value="#{Controller.information}"/>
        <hr/>
        <h:commandLink action="#{Controller.process}">
          <h:outputText id="clicker" value="Process"/>
        </h:commandLink>             
        <hr/>
        <h:commandLink action="#{Controller.reset}">
          <h:outputText id="reset" value="Reset"/>
        </h:commandLink>             
        <hr/>
        <h:commandLink action="#{Controller.setNull}">
          <h:outputText id="setNull" value="Set Null"/>
        </h:commandLink>             
      </h:form>
    </f:view>
  </body>
</html>The converter is declared for the String class in the faces configuration file. From the log message is appears to be invoked, however the object is not set to null.
I tested this with JSF 1.2_04-b20-p03 as well as 1.2_09-b02-FCS.
any other suggestions what could be causing this.

Similar Messages

  • Validations: Null value for LOVs

    See http://htmldb.oracle.com/pls/otn/f?p=24317:239
    I have a "Item is not null" validation on that LOV item. The item has "Display null value" set to Yes and a LOV of STATIC2:1,2,3
    If I leave the Null return value for the item to blank, the engine defaults it to %null% and the validation "knows" that this is really the same as a null value and so it kicks in (good).
    But if I change the Null return value to something like %, the validation doesn't complain, it thinks that this is a not-null value.
    Why the inconsistency? Does this mean that we are expected to use the default value of the Null return value i.e. leave it blank and let the engine put in %null%?
    Comments? Thanks

    Vikas - The declarative not null validation types recognize "actual" null or %null% as null values. This equivalence holds in numerous other situtations during page processing. Why does %null% get special treatment? A convention was chosen and that's it. And it works for almost everybody in almost all situations. In other words, it's useful, if not perfect. If you want a different value, you can specify one in the LOV (as you described). Then you can recognize and convert these values to null or %null% in an after-submit computation so that validations and other mechanisms work normally. (Perhaps it would help if the Builder created such a computation for items having LOVs with specified null values.) One use case for using a specified null return value might be where you want to distinguish a POSTed "actual" null value from the selected "null" value for which you have specified a null return value. Then you can tell if the value was selected from the LOV or whether it got a null value from the item's cache or source methods.
    Scott

  • How HANA handle NULL values

    Hi frzz,
    Can any one explain me how exactly HANA handles NULL values??
    Best Regards,
    Krishna.

    Hi Krishna,
    You can use IFNULL for the SQL queries/script instead of ISNULL . Since ISNULL is binary function and will be mostly used for the CE Functions based Calc views.
    Try using the same queries with IFNULL instead of ISNULL, it should work
    Best Regards
    Rahul Jha

  • Pro*C & SQLDA with NULL value for predicate column

    Hi: I am using a C program to update a table via a dynamic sql (method 4) and SQLDA. In the update statement predicate, I have place holders (as in TBLCOL=:C000). One of the columns in the predicate contains null values, so I set L[n] = 0, V[n] = pData (which pData[0] = '\0'), *(I[n]) = -1, and T[n] = 5 (for text). I cannot find the row that I know is there.
    I cannot change my statement to contain TBLCOL IS NULL, since I don't know ahead of time if I'm looking for rows with null values for this column. The Pro*C manual says that by setting the appropriate *(I[n]) = -1, it indicates to Oracle to simulate the "IS NULL" clause, and update the appropriate rows. In my case, I receive 1403 as SQLCODE when I use TBLCOL=:C000 vs TBLCOL IS NULL. What am I doing wrong? Thank you for your help.

    You should include these columns as well;
    ChangeType (see mxi_changetype)
    ValOwner (repository)
    UserID ("jobid=<>", usermskey, GUI (mmc), DG (dyngrp), reconcile)
    IdAudit  (This is the event task (add and del member for assignments)
    ParentAuditId (AuditID of parent which last updated the attribute, not consistent)
    ChangedBy (Holds the MSKEY of the user which last changed the attribute)
    ExpiryTime
    to make sure you get a fuller picture of the audit record.
    Your selection does not cover all events and descriptions
    br,
    Chris

  • How can I get null values for the later weeks

    Hi All,
    When I execute this code I get the records till current week.
    How can I display the output so that I get null values for the later weeks. (with the help of v_numOfWeeks variable in the code)
    Thanks,
    Vikram
    DECLARE
       v_query VARCHAR2(4000);
       TYPE ref_cursor IS REF CURSOR;
       v_refcur ref_cursor;
       v_sum NUMBER;
       v_id NUMBER;
       v_name VARCHAR2(1000);
       v_weeknum NUMBER;
       v_pernum NUMBER;
       v_numOfWeeks NUMBER := 5;
    BEGIN
    v_query := ' SELECT SUM(product_bkg), postn_id, postn_tbl.postn_name, b.week_num, b.period_num
                              FROM ops_cv_extract b, (SELECT row_id, desc_text postn_name
                          FROM s_postn) postn_tbl
                          WHERE lvl_6_id = 5767
                          AND fiscal_year = 2008
                          AND b.week_num < 4
                          AND b.period_num = 3
                          AND b.postn_id = TO_NUMBER(postn_tbl.row_id)
                          GROUP BY postn_id, postn_tbl.postn_name, b.week_num, b.period_num
                          ORDER BY  postn_tbl.postn_name, b.week_num';
    OPEN v_refcur FOR v_query;
    LOOP
       FETCH v_refcur INTO v_sum, v_id, v_name, v_weeknum, v_pernum;
       EXIT WHEN v_refcur%notfound;
       dbms_output.put_line('P'|| v_pernum||'W'|| v_weeknum||' '||v_name||' '||v_sum);
    END LOOP;
    END;
    This is the output when I execute this code.
    P3W1 COMM CNTRL ISAM 213 26961.61
    P3W2 COMM CNTRL ISAM 213 12870.4
    P3W3 COMM CNTRL ISAM 213 245.88
    P3W1 COMM CNTRL ISAM 273 72831.2
    P3W2 COMM CNTRL ISAM 273 8739.38
    P3W3 COMM CNTRL ISAM 273 3764.92
    P3W1 COMM CNTRL TAM 213 49844
    P3W2 COMM CNTRL TAM 213 20515.17
    P3W3 COMM CNTRL TAM 213 16167.46
    P3W2 COMM CNTRL TAM 216 12561.4
    P3W3 COMM CNTRL TAM 216 2027.1
    P3W1 COMM CNTRL TAM 273 -3336.71
    P3W2 COMM CNTRL TAM 273 -1376.68
    P3W3 COMM CNTRL TAM 273 19707.42
    P3W1 Damon Walters -609.07
    P3W2 Damon Walters 30030.24
    P3W3 Damon Walters 37475.1
    This is the output I'd like to get
    P3W1 COMM CNTRL ISAM 213 26961.61
    P3W2 COMM CNTRL ISAM 213 12870.4
    P3W3 COMM CNTRL ISAM 213 245.88
    P3W4 COMM CNTRL ISAM 213
    P3W5 COMM CNTRL ISAM 213
    P3W1 COMM CNTRL ISAM 273 72831.2
    P3W2 COMM CNTRL ISAM 273 8739.38
    P3W3 COMM CNTRL ISAM 273 3764.92
    P3W4 COMM CNTRL ISAM 273
    P3W5 COMM CNTRL ISAM 273
    P3W1 COMM CNTRL TAM 213 49844
    P3W2 COMM CNTRL TAM 213 20515.17
    P3W3 COMM CNTRL TAM 213 16167.46
    P3W4 COMM CNTRL TAM 213
    P3W5 COMM CNTRL TAM 213
    P3W1 COMM CNTRL TAM 273 -3336.71
    P3W2 COMM CNTRL TAM 273 -1376.68
    P3W3 COMM CNTRL TAM 273 19707.42
    P3W4 COMM CNTRL TAM 273
    P3W5 COMM CNTRL TAM 273
    P3W1 Damon Walters -609.07
    P3W2 Damon Walters 30030.24
    P3W3 Damon Walters 37475.1
    P3W4 Damon Walters
    P3W5 Damon Walters Edited by: polasa on Oct 28, 2008 6:42 PM

    Sure, in a Single SQL ->
    satyaki>
    satyaki>select * from v$version;
    BANNER
    Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - Prod
    PL/SQL Release 10.2.0.3.0 - Production
    CORE    10.2.0.3.0      Production
    TNS for 32-bit Windows: Version 10.2.0.3.0 - Production
    NLSRTL Version 10.2.0.3.0 - Production
    Elapsed: 00:00:00.01
    satyaki>
    satyaki>
    satyaki>-- Start Of Test Data --
    satyaki>with week_tab
      2  as
      3    (
      4      select 1 period_num, 1 week_num, 10 bkg1 from dual
      5      union all
      6      select 1, 2, 40 from dual
      7      union all
      8      select 1, 3, 30 from dual
      9      union all
    10      select 1, 2, 20 from dual
    11      union all
    12      select 1, 1, 10 from dual
    13      union all
    14      select 1, 1, 20 from dual
    15      union all
    16      select 1, 3, 10 from dual
    17      union all
    18      select 2, 1, 15 from dual
    19      union all
    20      select 2, 2, 20 from dual
    21      union all
    22      select 2, 3, 10 from dual
    23      union all
    24      select 2, 1, 15 from dual
    25      union all
    26      select 2, 2, 30 from dual
    27      union all
    28      select 2, 3, 20 from dual
    29    )
    30  -- End Of Test Data --
    31  select period_num,
    32         week_num,
    33         (
    34            select sum(week_tab.bkg1)
    35            from week_tab
    36            where period_num = m.period_num
    37            and   week_num   = m.week_num
    38            group by week_num, period_num
    39         ) sum_bkg1
    40  from (
    41        select dum.week_num,
    42              wk.period_num
    43        from (
    44                select 1 week_num from dual
    45                union all
    46                select 2 from dual
    47                union all
    48                select 3 from dual
    49                union all
    50                select 4 from dual
    51                union all
    52                select 5 from dual
    53              ) dum ,
    54              (
    55                select distinct period_num
    56                from week_tab
    57          ) wk
    58      ) m;
    PERIOD_NUM   WEEK_NUM   SUM_BKG1
             1          1         40
             1          2         60
             1          3         40
             1          4
             1          5
             2          1         30
             2          2         50
             2          3         30
             2          4
             2          5
    10 rows selected.
    Elapsed: 00:00:00.48
    satyaki>Regards.
    Satyaki De.

  • Can i use one JSF component's value for other component in the same page.

    Can i use one JSF component's value for other component in the same page.
    For example
    I have a <h:selectBooleanCheckbox id="myChk"> in my jsf page, i want to access its value for another component like:
    <h:commandButton disabled="#{myChk.checked}" action="myAction" value="myValue" />
    ** "myChk.checked" >> I am just asuming "checked" property is available...

    Bind the checkbox to a UIInput myChk property. Then you can reference this property from the page, e.g.
    <h:selectBooleanCheckbox binding="#{myBean.myChk}" onchange="submit();" />
    <h:commandButton disabled="#{myBean.myChk.value}" action="myAction" value="myValue" />

  • Oracle Discoverer: How to handle null value

    In Oracle Discoverer, I pull data from a folder. When I hit Null value for a column, I want to replace it with data from another folders column. Something like the functionality of "nvl" of a SQL statement. How can I do the following query in Discoveror :
    example: select nvl(table1.column1,table2.column2) from table1, table2
    where table1.column7 = table2.column7.

    Hi,
    You first need to include any column from folder table2 into your report so that Discoverer will do the join. (This assumes the join between table1 and table2 is set up in your EUL). Then you can create a calculation containing nvl(table1.column1,table2.column2) . You can then remove the column from folder table2 and the join will stay in your workbook.
    Hope that helps,
    Rod West

  • Oracle Discoveror: How to handle null value

    In Oracle Discoveror, I pull data from a folder. When I hit Null value for a column, I want to replace it with data from another folders column. Something like the functionality of "nvl" of a SQL statement. How can I do the following query in Discoveror :
    example: select nvl(table1.column1,table2.column2) from table1, table2
    where table1.column7 = table2.column7.

    Hi,
    You first need to include any column from folder table2 into your report so that Discoverer will do the join. (This assumes the join between table1 and table2 is set up in your EUL). Then you can create a calculation containing nvl(table1.column1,table2.column2) . You can then remove the column from folder table2 and the join will stay in your workbook.
    Hope that helps,
    Rod West

  • How do I set a NULL value for the parameter field

    Hi
    I've another question. I'm going to set single values for parameter fields.
    // e.g. set today for StartDate parameter field
    fc.setCurrentValue("", "StartDate", new Date());
    It should be possible to set a NULL value for date parameter fields.
    fc.setCurrentValue("", "StartDate", (Date)null);
    But this do not work. How do I set a NULL value correctly?
    Thank you in advance.
    Best regards,
    Thomas

    First question - is it a stored procedure parameter?
    You can't set a regular parameter field value to a null value.
    There was an issue with old version of the JRC, where it was allowing null to go through, but had unexpected behavior at times.
    Sincerely,
    Ted Ueda

  • Needing to convert a local "numeric" value to a string type using the expression browser.

    I am trying to convert a "numeric" local value to a string through the expression browser in order to supply a string arguement.  I am currently looking through the expression browser options, but I can not find any type of Number "ToString()" function.
    Solved!
    Go to Solution.

    Hi,
    Str() function
    ie
    locals.tostring = Str(locals.dec_value)
    Regards
    Ray Farmer

  • SQL query for empty string

    I am trying to execute the following SQl query, SELECT * FROM Failure WHERE ID = '123' AND RepairAction = ' ';, using the DB Tools Execute Query.vi. This query never finds the record in my database. My database contains a record where the ID filed contains the value of '123' and the RepairAction field is an empty string. If I remove the 'AND RepairAction ' ';' text from my query statement, the record is found. I believe my problem is that I am not using the correct syntax to describe and empty string. I have tried the following: '', ' ', "", " ", and NULL as empty string arguments, and none of these work.
    I was hoping someone might be able to tell me what the correct syntax is for an empty string or if there is another approach I need to take.
    Thank you in advance for your help,
    Jim
    Solved!
    Go to Solution.

    Hi,
    While creating your table "Failure", was the column "ID" delclared as intiger or varchar? If it is intiger and you use '123' , it wont return the results. You will have to try without the inverted comas ' '.
    Regards,
    Nitzz
    (Giver Kudos to good Answers, Mark it as a solution if your problem is Solved)

  • How to find as ascii value for a string or char in unicode system?

    Hello,
    How to find an ascii value for a string or char in unicode system?
    Thanks in Advance

    hi ,
    report demtest.
    data : c.
    field-symbols : <n> type x.
    data : rn type i.
    c = 'A'.
    assign c to <n> casting.
    move <n> to rn.
    write rn.
    This will convert 'A' to 65.
    Tom Demuyt
    How to convert ascii value to character.
    If I give input as 65 (ascill value) I want display 'A'.
    Below logic is for convert from character to ascii value , now I want to know how to convert ascii value to character.
    Naveen
    report demtest.
    *going from A to 65
    data : c value 'A'.
    field-symbols : <n> type x.
    data : rn type i.
    assign c to <n> casting.
    move <n> to rn.
    write rn.
    *going from 66 to B
    data : i type i value 66.
    data : x type x.
    field-symbols : <fc> type c.
    move i to x.
    assign x to <fc> casting type c.
    move <fc> to c.
    write c.
    regards,
    venkat.

  • I am gettng Null value for file when i am using a UDF as this

    String FName;
    DynamicConfiguration Conf = (DynamicConfiguration) container.getTransformationParameters(). get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);
    DynamicConfigurationKey key = DynamicConfigurationKey.create("http:/"+"/sap.com/xi/XI/System/File", "FileName");
    FName = Conf.get (key);
    if (FName == null)
    return "null";
    else
    return FName
    and my error is
    Attempt to process file failed with com.sap.aii.adapter.file.configuration.DynamicConfigurationException: The Adapter Message Property 'FileName' was configured as mandatory element, but there is no 'DynamicConfiguration' element in the XI Message headplease any on there to help me
    thanking you
    sridahr

    Hi,
    Did u selected the option filename from the Adapter message specific atribute of file adapter.
    When u  run the whole scneario that time this will work if u run the scneario using test message tab of message mapping it will give null value only.
    THe AMSA will work when u test it end to end.
    check it out.
    Advance parameter in file adapter dynamic file name
    Problem in dynamic file name in File reciever adapater
    /people/michal.krawczyk2/blog/2005/11/10/xi-the-same-filename-from-a-sender-to-a-receiver-file-adapter--sp14
    /people/william.li/blog/2006/04/18/dynamic-configuration-of-some-communication-channel-parameters-using-message-mapping
    chirag

  • ODI - Issue with handling null value

    Hi,
    I have a flat file as below. When i am trying to load the data file into Essbase through ODI, i am not able to load. If i given the Null value as 0, i'm able to load the file into Essbase. If we pass 0 in place of null value, blocks will be created in Essbase and it might cause the performance issue.
    Account,Product,Customer,Version,Year,BU,Data
    A1,P1,C1,V1,2010,BU1,7677
    A2,P2,C2,V2,2010,BU2,0908
    A3,P3,C3,V1,2010,BU3,
    Can any one help if there is any way to handle the null values to load the data into Essbase?
    Your help is more important to us as it is one of the critical one we are facing.
    Thanks
    V D Reddy

    Hi
    I am not using any query.
    Data column is empty (no data) for few records in my flat file. After the data load is done to Hyperion Essbase, in the excel retrieve should show me as #Missing. But ODI is defaultly loading it as 0 into Essbase.
    Is there any way to load it as #Missing?
    Thanks
    V D Reddy

  • Handling null value in where condition

    CREATE OR REPLACE package body GetRefCursors is
    function sfGetAccountInterval
    ( pFirstAccount in ACCOUNTS.ACCOUNT_NO%type
    ,pLastAccount in ACCOUNTS.ACCOUNT_NO%type)
    return csGetResultSet is
    csGetAccounts csGetResultSet;
    begin
    open csGetAccounts for
    SELECT accounts.account_no,accounts.name
    FROM accounts
    WHERE accounts.account_no BETWEEN pFirstAccount AND pLastAccount
    ORDER BY accounts.account_no;
    return csGetAccounts;
    end sfGetAccountInterval;
    end GetRefCursors;
    how can i handle the condition if pFirstAccount parameter having null value?
    do i need to use Dynamic SQL here?

    no need for dynamic stuff.
    You could use the NVL function, but it depends what you want... If you want NULL to be considered the lowest possible account number, then you could do something like
    nvl (pFirstAccount, 0)where the zero is the lowest possible number.

Maybe you are looking for