How to post null values from h:inputText?

Hello,
I have a form made of h:inputText fields that map to an entity class as the backing bean. Whenever I post the form from a web page, all the fields that I did not fill out and that are mapped to String fields in the entity class are set to "" (empty string) instead of null.
However, I would like to post null values to my entity, because that would indicate that the user did not fill out the field. In other contexts (outside of the web app) it is possible to set the fields to empty strings, but from the web app it should always be null. How can I get JSF to do this correctly?
Also, when reading entitys with null values from the database, these are converted to empty h:inputText fields, so this direction works as expected.
Ulrich

I haven't seen a solution for this as far.
This is how I do it:
public void action() {
    if (isEmpty(inputValue)) {
        // do your thing
    } else {
        // do your thing
public static boolean isEmpty(Object value) {
    if (value == null) {
        return true;
    if (value instanceof String && ((String) value).trim().length() == 0) {
        return true;
    if (value instanceof Collection && ((Collection) value).size() == 0) {
        return true;
    // And go so on .. make it an utility method.
    return false;
}

Similar Messages

  • How to replace NULL values from main table

    Dear all,
    I like to remove the NULL values from a main table field. Or the question is how to replace any part of the string field in MDM repository main table field.
    e.g.   I have a middle name field partly the value is NULL in some hundreds of records, I like to replace NULL values with Space
    any recommendation.
    Regards,
    Naeem

    Hi Naeem,
    You can try using Workflows for automatically replacing NULLs with any specific value.
    What you can do is: Create a workflow and set trigger action as Record Import, Record Create and Record Update. So, that whenever any change will occur in the repository; that workflow will trigger.
    Now create an assignment expression for replacing NULLs with any specific value and use that assignment expression in your workflow by using Assign Step in workflow.
    For exiting records, you will have to replace NULLs manually using the process given by Preethi else you can export those records in an Excel spreadsheet which have NULLs and then replace all NULLs with any string value and then reimport those records in your MDM repository.
    Hope this will solve your problem.
    Regards,
    Varun
    Edited by: Varun Agarwal on Dec 2, 2008 3:12 PM

  • How to eliminate null values from the data?

    This query displays data for a project with approval & submission dates...I'm trying to eliminate records that have null values in Approval & submission date columns at the same time. But rather keep the records that have atleast one submission date or approval date?
    SELECT distinct QP.QIP_id,
            Max(decode( Upper(QP.Status_CD), Upper('Approved') , Effective_date, null ))  as Approved_date,
            Max( decode( Upper(QP.Status_CD), Upper('Submitted') , Effective_date, null ) ) as Submitted_date
             FROM  Llp_Sys.Project_Status QP
             WHERE SYSDATE >= qp.effective_date
                AND (qp.terminated_date IS NULL OR SYSDATE < qp.terminated_date)
            GROUP by QP.QIP_ID,Qp.Status_CD
            order by QP.QIP_ID

    francislazaro wrote:
    This query displays data for a project with approval & submission dates...I'm trying to eliminate records that have null values in Approval & submission date columns at the same time. But rather keep the records that have atleast one submission date or approval date?
    SELECT distinct QP.QIP_id,
    Max(decode( Upper(QP.Status_CD), Upper('Approved') , Effective_date, null ))  as Approved_date,
    Max( decode( Upper(QP.Status_CD), Upper('Submitted') , Effective_date, null ) ) as Submitted_date
    FROM  Llp_Sys.Project_Status QP
    WHERE SYSDATE >= qp.effective_date
    AND (qp.terminated_date IS NULL OR SYSDATE < qp.terminated_date)
    GROUP by QP.QIP_ID,Qp.Status_CD
    order by QP.QIP_ID
    based on my assumption, will the following not work ? if so then post some sample data and expected output (simplify as much as possible)
    SELECT *
      FROM (SELECT DISTINCT qp.qip_id,
                            MAX(DECODE(UPPER(qp.status_cd),
                                       UPPER('Approved'), effective_date,
                                       NULL
                                      )) AS approved_date,
                            MAX(DECODE(UPPER(qp.status_cd),
                                       UPPER('Submitted'), effective_date,
                                       NULL
                                      )) AS submitted_date
                       FROM llp_sys.project_status qp
                      WHERE SYSDATE >= qp.effective_date
                        AND (   qp.terminated_date IS NULL
                             OR SYSDATE < qp.terminated_date
                   GROUP BY qp.qip_id, qp.status_cd
                   ORDER BY qp.qip_id)
    WHERE approved_date IS NOT NULL OR submitted_date IS NOT NULL;Edited by: Clearance 6`- 8`` on Jul 9, 2010 12:46 PM

  • How to include null values from DB

    Hi,
    I want to see all columns values even though it may contain null values. Right now all null columns are being suppresed by XSQL. Is there any way i can configure this.
    Thanks in advance
    Regards
    Veera

    use the following attribute in the <xsql:query> element (see the xsql help!):
    <xsql:query null-indicator = "yes">..
    </xsql:query>
    Indicates whether to signal that a column's value is NULL by including the NULL="Y" attribute on the element for the column. By default, columns with NULL values are omitted from the output. Valid values are 'yes' and 'no'.(Default value is 'no')

  • How to remove NULL values from crosstab sheet in Viewer/Plus.

    I created a worksheet as crosstab. The sheet shows blanks in Desktop when there is no data in the cell, but the same sheet is showing NULL in Viewer. Is there any solution to make NULL as 0 or blank in Viewer?
    Thank you.

    Here you can find solution for this issue and its works for me......
    Show null values as

  • How to remove null values from list?

    I had created a list in forms 6i and I am getting list values at run time using add_list_item function. The problem is I am getting null value at end of the list. In the property pallet I kept required yes and set the initial value but it is not removing null value. Can any one help me. Thank you.......

    Hello
    Sorry mis-read question on first reply.
    1. Have you set a default value?
    2. Is this default value still in your list?
    3. What happens if you default the list's value to a value you know exists after you have populated it?
    Cheers
    Q
    Message was edited by:
    Q_STEPHENSON

  • How to pass null values From DTW

    I have update value of Acctntcode of OACT table
    Now i have to insert null in the field of Acctntcode From DTW (Data Transfer WorkBench)
    How Can i do it ?

    Hi,
    little late to the party on this one but I had a similar issue today and found the answer.
    Use a "/" (forward-slash) in your DTW file and it will set the field to NULL for you.
    I don't know if this works for numeric fields (probably not) but it worked for me on several string fields I needed to clear in various Master Data objects.
    HTH!
    Regards,
    Steve

  • How to fetch null values from a table

    Hi,
    This is a Attendance report
    Table Name : Attn_details ( Only 3 records stored in this table )
    EDate Etype
    04/03/2010 A
    05/03/2010 C
    06/03/2010 X
    user Enter From date : 01/03/2010
    To date : 10/03/2010
    I need the output 01/03/2010 to 10/03/2010
    01/03/2010 Null
    02/03/2010 Null
    03/03/2010 Null
    07/03/2010 Null
    08/03/2010 Null
    09/03/2010 Null
    10/03/2010 Null
    How to write a sql query, this is Urgent requirement, Help Me.

    EDate Etype Empcode
    01/03/2010 A 001
    02/03/2010 C 001
    04/03/2010 X 001
    02/03/2010 A 002
    01/03/2010 P 003
    5 records Like this stored in that table.
    user Enter From date : 01/03/2010
    To date : 04/03/2010
    for that employee code attendance date not marking that date only should come into the report.
    ECode 002 attendance not marked in the date of 01/03/2010 , 03/03/2010,04/03/2010
    003 attendance not marked in the date of 02/03/2010 , 03/03/2010,04/03/2010
    I need the output 01/03/2010 to 04/03/2010
    03/03/2010 Null 001
    01/03/2010 Null 002
    03/03/2010 Null 002
    04/03/2010 Null 002
    02/03/2010 Null 003
    03/03/2010 Null 003
    04/03/2010 Null 003
    i think now u clear the my requirement. how can i write the query.

  • How to eliminate NULL values from case statement?

    I have the following query where I am trying to eliminate the NULL record.  How can I do this?  My query:
    select
    AttendedSchoolLast3Months = case
    when d.scrnval_id = 'AA5639E4-E60C-473F-9B72-354472C11F5B' and d.picklist_value = 'BC349A1E-65A1-4497-A38A-116C83B2028F' then 2 --No
    when d.scrnval_id = 'AA5639E4-E60C-473F-9B72-354472C11F5B' and d.picklist_value = 'A529C643-60A7-4D79-AC67-1A8F70791934' then 1 --Yes
    end
    From [evolv_cs].[dbo].[test_header] [test_header_rv] WITH (NOLOCK)
    CROSS APPLY [dbo].[fn_getTestSetupFormDetails](null, [test_header_rv].[test_setup_header_id]) AS [test_header]
    CROSS APPLY [dbo].[fn_getTestSetupFormDetails]([test_header].[test_setup_details_id], null) AS [test_details]
    JOIN [evolv_reports].[dbo].[test_details_answers_expanded_view] d WITH (NOLOCK) ON
    [test_header_rv].[test_header_id] = d.[test_header_id]
    AND [test_details].[test_setup_details_id] = d.[test_setup_details_id]
    join [user_defined_lut_rv] udl1 with(nolock) on udl1.[user_defined_lut_id] = d.picklist_value
    join people_rv p (nolock) on d.people_id = p.people_id
    where d.actual_date between '9/1/13' and '9/30/13'
    and d.people_id = '7A9ACEE4-ABD5-4905-A54E-659A81048A1A'
    And the result currently is:
    AttendedSchoolLast3Months
    1
    NULL
    When I ran this query:
    select distinct --attendedschoollast3months
    d.*
    From [evolv_cs].[dbo].[test_header] [test_header_rv] WITH (NOLOCK)
    CROSS APPLY [dbo].[fn_getTestSetupFormDetails](null, [test_header_rv].[test_setup_header_id]) AS [test_header]
    CROSS APPLY [dbo].[fn_getTestSetupFormDetails]([test_header].[test_setup_details_id], null) AS [test_details]
    JOIN [evolv_reports].[dbo].[test_details_answers_expanded_view] d WITH (NOLOCK) ON
    [test_header_rv].[test_header_id] = d.[test_header_id]
    AND [test_details].[test_setup_details_id] = d.[test_setup_details_id]
    join [user_defined_lut_rv] udl1 with(nolock) on udl1.[user_defined_lut_id] = d.picklist_value
    --join [education_level] e (nolock) on e.[EducationLevel] = udl1.[description]
    join people_rv p (nolock) on d.people_id = p.people_id
    where d.actual_date between '9/1/13' and '9/30/13'
    and d.people_id = '7A9ACEE4-ABD5-4905-A54E-659A81048A1A'
    I get this:
    event_log_id people_id group_profile_id actual_date test_header_id test_setup_details_id test_domains_info_id question_caption question_code test_details_answers_id update_log_id test_details_id numeric_value scrnval_id picklist_value remarks narrative test_setup_details_answers_id is_checked date_value details_type_code test_setup_answers_caption test_setup_answers_order test_setup_answers_value output_code answers_category_id answers_category answers_category_code
    24E8F88F-9648-4714-9394-D5A3F642C0F0 7A9ACEE4-ABD5-4905-A54E-659A81048A1A NULL 2013-09-26 17:00:00.000 24E8F88F-9648-4714-9394-D5A3F642C0F0 67CDCF44-6308-4E15-8543-3C85DE4C6D4D NULL Attended school in the last 3 months NULL 1BB75044-A65C-4464-ADB9-0CA991019907 7CDD1A4F-41F4-403C-A85E-7FF51B761FF0 3F04BBFF-8DE9-4283-842F-E53A536E3E46 NULL AA5639E4-E60C-473F-9B72-354472C11F5B A529C643-60A7-4D79-AC67-1A8F70791934 NULL NULL 5979600C-B4E6-42DF-BF45-8AFF15ACDD7D 0 NULL PICKLIST Click here for list 1 NULL NULL NULL NULL NULL
    24E8F88F-9648-4714-9394-D5A3F642C0F0 7A9ACEE4-ABD5-4905-A54E-659A81048A1A NULL 2013-09-26 17:00:00.000 24E8F88F-9648-4714-9394-D5A3F642C0F0 EBDFBCA5-6E57-4907-9DEF-A1E118F3AB2D NULL Highest grade completed NULL 8F7F4644-4E67-4821-B0FC-A192389F994D 7CDD1A4F-41F4-403C-A85E-7FF51B761FF0 F6C59E67-EC74-4F0C-8EE8-AB372F22255D NULL 4536DD06-871D-4FA7-BA8A-552DB2CA59BC D77F0CAB-505E-4838-AECE-01BAAE8B8EB2 NULL NULL E7C9ECB7-7B40-4115-A6DB-BC752116D68D 0 NULL PICKLIST Click here for list 1 NULL NULL NULL NULL NULL
    Ryan D

    Hi, 
    what I understood from above is that u want to filter NULL records and want to display only not null records. Try below query.
    SELECT * FROM(select
    AttendedSchoolLast3Months = case
    when d.scrnval_id = 'AA5639E4-E60C-473F-9B72-354472C11F5B' and d.picklist_value = 'BC349A1E-65A1-4497-A38A-116C83B2028F' then 2 --No
    when d.scrnval_id = 'AA5639E4-E60C-473F-9B72-354472C11F5B' and d.picklist_value = 'A529C643-60A7-4D79-AC67-1A8F70791934' then 1 --Yes
    end
    From [evolv_cs].[dbo].[test_header] [test_header_rv] WITH (NOLOCK)
    CROSS APPLY [dbo].[fn_getTestSetupFormDetails](null, [test_header_rv].[test_setup_header_id]) AS [test_header]
    CROSS APPLY [dbo].[fn_getTestSetupFormDetails]([test_header].[test_setup_details_id], null) AS [test_details]
    JOIN [evolv_reports].[dbo].[test_details_answers_expanded_view] d WITH (NOLOCK) ON
    [test_header_rv].[test_header_id] = d.[test_header_id]
    AND [test_details].[test_setup_details_id] = d.[test_setup_details_id]
    join [user_defined_lut_rv] udl1 with(nolock) on udl1.[user_defined_lut_id] = d.picklist_value
    join people_rv p (nolock) on d.people_id = p.people_id
    where d.actual_date between '9/1/13' and '9/30/13'
    and d.people_id = '7A9ACEE4-ABD5-4905-A54E-659A81048A1A' ) AWHERE AttendedSchoolLast3Months IS NOT NULLTry this query.
    Thanks Shiven:) If Answer is Helpful, Please Vote

  • How to fetch null values from DB

    I need to fetch records where a field value is Null or nothing or space.
    I tried :
    where <field > eq space.
    But this did not fetch any records though there are records in DB.
    Is there any other way?
    Thanks
    Kiran

    Hi kiran,
    As you say, WHERE<field > EQ space should be works, try using  WHERE <field > IS NULL..
    Regards,
    Alejandro López

  • How can I delete null values from List Item?

    Hi Friends,
    I used List item for field job_Type, I entered values in List item at design time through property pallet. When I run form I will see null values in this List Item.
    How can I remove these null values from the List?
    Best regards,
    Shahzad

    Dear Shahzad,
    It can be removed by adding the following code in the When-new-Form-Instance.
    Set_item_property('List name', required, property_true);
    :block_name.list_name := <put your default value here>; (If you didn't oput the default value, then you will get some problem and the cursor may not navigate away from the list).
    Senthil Alagu .P.

  • How to get each value from a parameter passed like this '(25,23,35,1)'

    Hi
    One of the parameter passed to the function is
    FUNCTION f_main_facility(pi_flag_codes VARCHAR2) return gc_result_set AS
    pi_flag_codes will be passed a value in this way '(25,23,35,1)'
    How to get each value from the string
    like 25 first time
    23 second time
    35 third time
    1 fourth time
    I need to build a select query with each value as shown below:-
    (SELECT t2.org_id, t4.description
    from org_name t2, ref_org_name t3, code_table t4
    where t2.att_data = t4.code
    and t3.ref_code = t2.att_type
    and t2.att_type = 25 and t3.code_type = t4.code_type
    and to_date('01-JAN-10', 'DD-MON-YY') between t2.att_start_date AND t2.att_end_date) q1,
    (SELECT t2.org_id, t4.description
    from org_name t2, ref_org_name t3,code_table t4
    where t2.att_data = t4.code
    and t3.ref_code = t2.att_type
    and t2.att_type = 23 and t3.code_type = t4.code_type
    and to_date('01-JAN-10', 'DD-MON-YY') between t2.att_start_date AND t2.att_end_date) q2,
    (SELECT t2.org_id, RTRIM(xmlagg(xmlelement(e, t4.description || ';')
    ORDER BY t4.description).EXTRACT('//text()'), ';') AS DESCRIPTION
    from org_name t2, ref_org_name t3,code_table t4
    where t2.att_data = t4.code
    and t3.ref_code = t2.att_type
    and t2.att_type = 35 and t3.code_type = t4.code_type
    and to_date('01-JAN-10', 'DD-MON-YY') between t2.att_start_date AND t2.att_end_date
    group by t2.org_id) q3,
    (SELECT t2.org_id, t4.description
    from org_name t2, ref_org_name t3, code_table t4
    where t2.att_data = t4.code
    and t3.ref_code = t2.att_type
    and t2.att_type = 1 and t3.code_type = t4.code_type
    and to_date('01-JAN-10', 'DD-MON-YY') between t2.att_start_date AND t2.att_end_date) q4
    Please help me with extracting each alue from the parm '(25,23,35,1)' for the above purpose. Thank You.

    chris227 wrote:
    I would propose the usage of regexp for readibiliy purposes and only in the case if this doesnt perform well, look at solutions using substr etc.
    select
    regexp_substr( '(25,23,35,1)', '\d+', 1, 1) s1
    ,regexp_substr( '(25,23,35,1)', '\d+', 1, 2) s2
    ,regexp_substr( '(25,23,35,1)', '\d+', 1, 3) s3
    ,regexp_substr( '(25,23,35,1)', '\d+', 1, 4) s4
    from dual 
    S1     S2     S3     S4
    "25"     "23"     "35"     "1"In pl/sql you do something like l_val:= regexp_substr( '(25,23,35,1)', '\d+', 1, 1);
    If t2.att_type is type of number you will do:
    t2.att_type= to_number(regexp_substr( '(25,23,35,1)', '\d+', 1, 1))Edited by: chris227 on 01.03.2013 08:00Sir,
    I am using oracle 10g.
    In the process of getting each number from the parm '(25,23,35,1)' , I also need the position of the number
    say 25 is at 1 position.
    23 is at 2
    35 is at 3
    1 is at 4.
    the reason I need that is when I build seperate select for each value, I need to add the query number at the end of the select query.
    Please see the code I wrote for it, But the select query is having error:-
    BEGIN
    IF(pi_flag_codes IS NOT NULL) THEN
    SELECT length(V_CNT) - length(replace(V_CNT,',','')) FROM+ ----> the compiler gives an error for this select query : PLS-00428:
    *(SELECT '(25,23,35,1)' V_CNT  FROM dual);*
    DBMS_OUTPUT.PUT_LINE(V_CNT);
    -- V_CNT := 3;
    FOR L_CNT IN 0..V_CNT LOOP
    if L_CNT=0 then
    V_S_POS:=1;
    V_E_POS:=instr(pi_flag_codes, ',', 1, 1)-1;
    else
    V_S_POS:=instr(pi_flag_codes,',',1,L_CNT)+1;
    V_E_POS:=instr(pi_flag_codes, ',', 1, L_CNT+1)-V_S_POS;
    end if;
    if L_CNT=V_CNT then
    V_ID:=TO_NUMBER(substr(pi_flag_codes,V_S_POS));
    else
    V_ID:=TO_NUMBER(substr(pi_flag_codes,V_S_POS,V_E_POS));
    end if;
    VN_ATYPE := ' t2.att_type = ' || V_ID;
    rec_count := rec_count +1;
    query_no := 'Q' || rec_count;
    Pls help me with fetching each value to build the where cond of the select query along with the query number.
    Thank You.

  • How to get actual value from LOV list

    Like Subject says: How to get actual value from LOV list. Any help will be appreciated.
    Thanks.

    Thanks Shay, I did it with bind variable because I'm not using JSF. Is there any chance to post solution using standard JSTL or HTML expression. I have something like this: LOV displays some Companies names:
    <html:select property="UserJobCompanyId"
                             disabled="${!bindings[\'UserJobCompanyId\'].updateable}"
                             onchange="submitform();">
                  <html:optionsCollection label="prompt" value="index" property="UserJobCompanyId.displayData"/>                                                     
                </html:select>and I want to get CompanyID of selected Company.
    Thanks, again.

  • How to get column value from DB grid

    Hi!
    I wander how to get col value from GridControl?
    My app consists of one rowsetinfo with two
    columns CODE and DESCRIPTION and a jbutton
    titled SELECT. When user clicks SELECT button
    the app should show the value of the CODE col
    of the selected row in GridControl.
    I wander how to make this action ?
    XxpsTransTimesMasterIter.setAttributeInfo( new AttributeInfo[] {
    CODEXxpsTransTimesMasterIter,
    DESCRIPTIONXxpsTransTimesMasterIter} );
    XxpsTransTimesMasterIter.setName("XxpsTransTimes");
    XxpsTransTimesMasterIter.setQueryInfo(new QueryInfo(
    "XxpsTransTimesMasterIterViewUsage",
    "lov.XxpsTransTimes",
    "CODE, DESCRIPTION",
    "XXPS_TRANS_TIMES",
    null,
    null
    ));

    Hi,
    You could attach an ActionListener on the JButton, and try the following code :
    NavigationManager fm = NavigationManager.getNavigationManager();
    DataItem dataItem = fm.getFocusedControl().getDataItem();
    ImmediateAccess col_code = null;
    String code = null;
    if (dataItem != null && dataItem instanceof RowsetAccess) {
    RowsetAccess rowset = (RowsetAccess)dataItem;
    try {
    col_code = (ImmediateAccess) rowset.getColumnItem("CODE");
    code = col_code.getValueAsString();
    } catch (DuplicateColumnException de) {
    return;
    } catch (ColumnNotFoundException ce) {
    return;
    } catch (SQLException se) {
    return;
    JTextField tf = new JtextField();
    tf.setText(code);
    I haven't tested this code.
    I am curious to know, the Object type of the dataItem.If it doesnot happen to be RowsetAccess ..try.. ScrollableRowsetAccess OR ImmediateAccess.
    Your code would change accordingly, depending on the instance.Refer to the product documentation for this.
    Do let me know, if this works.
    TIA
    Sandeep

  • How to get attribute value from standard page ?

    Hi,
    How to get attribute value from standard page ?
    String str = (String)vo.getCurrentRow().getAttrbute("RunId");
    But this value is returning a null value ....
    Can anyone help me to get this attribute value which is actually having a actual value .

    getCurrentRow() would always return null if no setCurrentRow() is used.
    Please check the page design and understand how many rows of VO are there. You can also use the following to get the row:
    vo.reset();
    vo.next();
    Regards
    Sumit

Maybe you are looking for