SpinnerNumberModel and null or empty values
Hello,
I have a GUI which is used to enter data which will be stored in the database. Some of these fields are JSpinners. Most of them are representing integers (the column in the database is also an integer).
The user should have the possibility for some JSpinners to not fill it in. Then this is translated to <null> in the database. But my JSpinners are using the SpinnerNumberModel and by default '0' is shown. When you empty this field then '0' is automatically filled in, because a null value is not supported by the SpinnerNumberModel.
I have searched this forum and apparently I should make a custom model that supports null values. I have tried that but without succes because I couldn't find an example.
Is this a possible solution and if it is, does someone has an example of a custom spinnermodel which supports null values?
Thx,
Mynca
http://java.sun.com/docs/books/tutorial/uiswing/components/spinner.html#model
Might be a good start.
Similar Messages
-
System.Exception: null or empty values
Have designed a 4 part form Using DW MX, ASP.NET C# and MySQL
and currently getting the below error when moving from one page to
the next.
The web.config file is on the server, there are no null or
empty values, and the key tags match.
I am new to applicaiton development in DW and am now stuck -
any suggestions?
System.Exception: This page has a MM:DataSet, MM:Insert,
MM:Update or MM:Delete tag with a null or empty value for the
ConnectionString and DatabaseType attributes.
Often, such values come from application settings in the
web.config file. That file might be missing from the server
executing this page. Or, it might be missing the particular add key
tags for the database connection this page uses. If you are using
Dreamweaver, look for the web.config file in the local root folder
of your Dreamweaver site. Once you find this file, you can either:
Put this file onto the server that is executing this page.
Copy the add key tags from the web.config in the local root
folder of your Dreamweaver site and paste them into the web.config
file in the server that is executing this page.
at DreamweaverCtrls.DataSet.DoInit()
Texthttp://java.sun.com/docs/books/tutorial/uiswing/components/spinner.html#model
Might be a good start. -
How to define null or empty value in BAPI function modules?
Hi,
I have problem with BAPI functions, where some parameters are mandatory.
For example: when I try to use HR BAPI's(BAPI_PERSDATA_CHANGE, etc.) I have to insert parameters like SUBTYPE,OBJECTID,LOCKINDICATOR. The PA0002 table that is used from this BAPI doesn't have SUBTYPE, OBJECTID, LOCKINDICATOR, for any of the records that I would like to select.
So what I tried, was to put a ' ', to indicate that is empty. It returned an error message saying "Make an entry in all required fields". Next tried to put in some values for these fields -- and it returned an error message saying "No data selected from 0002 for this period".
I also tried to run BAPI_FAMILY_CHANGE that uses data from table PA0021. Here I found some records with SUBTYPE, OBJECTID fields that were not empty, but LOCKINDICATOR was still missing. So I tried to put LOCINDICATOR value directly in to database (with MS SQL Enterprise Manager). After that I was able to use BAPI_FAMILY_CHANGE.
I think that manually inserting data in database is not normal procedure.
Is there something that I have missed out?
I mean -- how can I get this to work without inserting data directly in database?
How can I define null or empty value in BAPI function modules?
Thank you in advance.
Best regards,
MihailDefining an empty value for a parm in a table is easy.
First get the function's definition from the SAP system
Second only populate the fields for which you have a value to set
Third execute the function.
The JCO takes care of the rest.
Enjoy -
How to see a null or empty value in JFormattedTextField
Hello, I am having a problem. I'm trying to use a JFormattedTextField, and I keep getting errors.
I know what is causing the error, but I don't know how to fix it.
Here is my code:
String cf = countFTX.getText();
if(cf.equals(" ")) {
i = Integer.valueOf(countJTX.getText());
}else{ i = Integer.valueOf(countFTX.getText()); }what happens is I get an error when it goes to change it into an int. Because it see's it as being (" ") and not (" ") or even ("") so it doesn't fit into my if statement. And returns it being false, then tries to turn it into an int, and blows up there.
Now how can I fix my if statement to be able to see if nothing was entered, and if so then use the countJTX and not the countFTX?
countJTX is a regular JTextField, and countFTX is a JFormattedTextField.
the JTX is filled automaticaly with an int, and if there needs to be a change, the user puts it into the FTX. (so you understand the logic behind it)
any ideas? or should i just revert to not using the FTX?you need to know the differenct between NULL and "" (empty) of a string. Also both of these values cann't converted to in integer so you can not call Integer.valueOf(cf). I don't understand why you need to do that. Instead:
String cf = countFTX.getText();
if(cf == null || cf.length() == 0)) {
i = ?; //something you want i to be when cf is null or empty but not call Integer.valueOf(countJTX.getText());
}else{
i = Integer.valueOf(cf);
}Also, you may need to add try/catch exceptions. -
Using % to get all including null or empty values
dear all;
Please find below the following sample data
create table t1
ID varchar2(200),
time_create date
insert into t1
(id, time_create)
values
('A', sysdate);
insert into t1
(id, time_create)
values
('B', sysdate);
insert into t1
(id, time_create)
values
(null, sysdate);
I have the following sql statement below
select * from t1
where t1.id like decode(:id, 'ALL', '%', :id);now, I have a situation where if the user input is ALL, I would like to get all results including the null values or space values, how can I modify the decode statement to do that.
This is the output I want below for ALL
ID TIME_CREATE
A 5/23/2011 11:14:23 PM
B 5/23/2011 11:14:24 PM
5/23/2011 11:14:25 PMAll help is appreciated. Thank you.Both work in exactly the same manner.
The OR condition says either boolean expression needs to be true for the row to be returned, so when :id = 'ALL' (and bind variable is set to 'ALL')- all rows are returned regardless.
When id = :ID, only values that are equal to your bind variable will be returned.
You could modify to this to provide even more flexibility
select * from t1
where :ID = 'ALL'
OR like :ID;
Scott -
Sorting and null for monetary values in a report
All,
I think this should be an easy one, and I've just missed something obvious.
I have a standard report in APEX 3.2.1 that includes a column with a monetary amount in it. I want the column to show the UK Pound sign, be sortable, and show nulls where appropriate.
The issue I have is I can't find a way to achieve all 3 in a satisfctory way. As I see it the options would be:
1) In the SQL for the report, concat the pound sign to the column required, e.g. SELECT '£'||amount FROM....
The issue is that this makes this field a CHAR field, so sorting would not sort in the same way as for a number field.
2) Use the Number format FML999...etc. in the Column Attribute.
The problem with this is that this is a multi-country database, and the default monetary unit is set to the US dollar.
3) Use the HTML expression box in the Column attribute to display £#COL#
This fulfills the pound sign and retaining the number format, but unfortunately a null value is displayed as a £ sign with no numbers. I can't think how to get it to leave that value in the report as completely blank.
As I said, I'm sure I've missed soemthing obvious. If anyone can spot how to achieve this it'd be much appreciated.
Regards,
Jon.>
2) Use the Number format FML999...etc. in the Column Attribute.
The problem with this is that this is a multi-country database, and the default monetary unit is set to the US dollar.
>
The NLS currency symbol can be modified on the fly if you have some means of identifying user location/preference: {thread:id=990848} (ignore the last post)
However, it probably doesn't make sense to do that—£100 ≠ $100 (at least I hope not!)—unless there's some kind of conversion occurring in the report? Is there a currency stored along with the amount?
>
3) Use the HTML expression box in the Column attribute to display £#COL#
This fulfills the pound sign and retaining the number format, but unfortunately a null value is displayed as a £ sign with no numbers. I can't think how to get it to leave that value in the report as completely blank.
>
Use 2 columns, one for the amount, and one for the currency, with a switch to include or exclude the latter as necessary:
select
ename
, comm amount
, nvl2(comm, '£', null) currency
from
emp
where
job in ('SALESMAN', 'MANAGER')
ENAME AMOUNT CURRENCY
ALLEN 300 £
WARD 500 £
JONES
MARTIN 1400 £
BLAKE
CLARK
TURNER 0 £ Then use both columns in the Amount HTML Expression:
#CURRENCY##AMOUNT# -
I created a report with multiple fields. I would like to create a generic formula in which it evaluates all the values and if it found a null or empty value it will be replaced by a 'N/A'. I was searching in the forums and I found the following formula
if (isnull() or ( ='')) then
"Display the required text"
else
when I tried to use it i had an error that the value must be boolean. Is there is a way where I can change all the fields as string?? and a assign "N/A"
or
how can I assign a "N/A"to a boolean field??
also I have approx. 140 fields to evaluate, does the formula can be generic or I will need to create a formula for each variable??
thanksUsually when Crystal runs across a field that is NULL, it immediately stops executing the formula, unless the field is enclosed within IsNull(). However, I'm not sure if that is the case for a parameter being passed to a function. So, you may be able to create a function like (Formula Workshop -> Create Custom Functions -> Add; basic syntax):
function DisplayString (inVal as string) as string
if (isnull(inVal) or (inVal ='')) then
DisplayString = "N/A"
else
DisplayString = inVal
end if
If Crystal does stop when passing a NULL value as a parameter, then you could code a similar function (without the isnull()), and check the Convert NULL Database Values to Default option on the File -> Report Options panel.
You would need to create one such function for each data type that you want to show "N/A" for, and for data types other than string, convert the value to a string when it is not null.
These functions could then be used in the Display String formula for the field on the report.
The only other way I can think of achieving this would be to base the report(s) on an SQL Command and convert NULL values to "N/A" there. It might be a bit easier to do in an SQL Command, but probably not a whole bunch.
Or, educate your users that when nothing is printed, it means that it's not applicable!
HTH,
Carl -
Cfprocparam type="OUT" brings back empty value
ISSUE OBJECTIVE:
After conversion from CF 5 to CFMX 7, <cfprocparam
type="OUT" brings back empty value
OUR STORED PROC:
<cfstoredproc procedure="sp_rass_user_guidance"
datasource="#rass_data_source#" returncode="YES">
<cfprocparam type="IN" dbvarname="@status" value="2"
cfsqltype="CF_SQL_INTEGER">
<cfprocparam type="IN" dbvarname="@addname"
value="#form.newVersionName#" cfsqltype="CF_SQL_CHAR">
<cfprocparam type="IN" dbvarname="@userid"
value="#client.userid#" cfsqltype="CF_SQL_CHAR">
<cfprocparam type="OUT" dbvarname="@rc" variable="rc"
cfsqltype="CF_SQL_SMALLINT">
<cfprocparam type="OUT" dbvarname="@reason"
variable="reason" cfsqltype="CF_SQL_VARCHAR">
<cfprocresult name="retrieveVersions">
</cfstoredproc>
In SQL query anylizer this stored proc brings back some
values for variables rc and reason, but empty values on CF pages.
Cf gurus please helpSomething sounds fishy. I'm not sure what more you could do
at the database, since PL/SQL VARCHAR2 variables have a max length
of 32,767 (as opposed to the VARCHAR2 data type limit of 4000
bytes). Should let you return more than 900 bytes! Perhaps you may
need to look into your kernal parameters, or Oracle parameters like
sga_max_size, etc.
You say that "Long Buffer Varchar is checked and set to
max"... what value? Also, what version of ColdFusion are you using,
as I can not "check" Long Text Buffer (chr) but only supply a
value, or I can check CLOB (or BLOB), where checking CLOB will
override the Long Text Buffer (chr) value.
Phil -
How to differentiate the EMPTY Records and Null Values in DSO
Hello....how is everyone here?? Ehehehe!
I try to load some data from the flat file which contains some EMPTY data and Null Values for the records. The data type for the InfoObjects of the fields "Quantity" is "number". The sample data from the flat file (CSV) are as below:
Food Quantity
Hamburger - 12
Cheese - 0
Vegetable - (Empty)
When I try to load the above sample data to the DSO, I get the results of the data as follow:
Food Quantity
Hamburger - 12.000
Cheese - 0.000
Vegetable - 0.000
In this case, how can the user differentiate whether the records is contain empty value of null values in DSO? This is kinda of hard to differentiate the both scenarios above. Is there any way to differentiate the scenarios described here?
Thanks alot =)Hi Fluffy,
It depends on the initial values of the data type
The inital values For quantity/Currency/ Numbers it takes spaces as 0
for char it is SPACE
We cannot differeniate between space and null values.
IF you have to force this then define quantity as char and load the data. we will not have units and aggregation in this case.
Hope this helps.
PV -
Distinguishing between empty string and null values
hi all,
I am using an ODBC connection to connect my java app to database using JDBCODBC driver. I have 2 columns 'aColumn' and 'bColumn' in my table, both allow null values. I have one row in it, which has null value in aColumn and empty string in bColumn. I retrieve this row's data and assign it to 2 columns : 'aColumnVar' and 'bColumnVar' respectively. I find out that both 'aColumnVar' and 'bColumnVar' variables has null values (although bColumnVar should has an empty string as its value). Now my ODBC connection Data Source has the option "Use ANSI nulls, paddings, and warnings" ON. I turn it off and try again. This time both 'aColumnVar' and 'bColumnVar' variables has empty string as values (although aColumnVar should has null as its value).
How can I make sure that i can get the data exactly as it is in the database in my variables?
Thanksthere is a wasNull() method on ResultSet. After you
have obtained the value of a column e.g. by calling a
method like getString you can call wasNull and if it
returns true then the value on the database is null.
Check the java docs, it might explain it better
http://java.sun.com/j2se/1.4.1/docs/api/java/sql/Result
et.html#wasNull()I am using MS SQL Server 7.0 under Windows NT 4.0 with JDK 1.2. My ODBC connection Data Source has to have the option "Use ANSI nulls, paddings, and warnings" ON.
I try the wasNull() method but it is doing the same thing i.e. telling me that a column is null when in database it is null (right); and a column is null when in database it is an empty string (wrong). I suspect it is something to do with the JDBC-ODBC driver I am using. -
How to check empty string and null? Assign same value to multiple variables
Hi,
1.
How do I check for empty string and null?
in_value IN VARCHAR2
2. Also how do I assign same value to multiple variables?
var_one NUMBER := 0;
var_two NUMBER := 0;
var_one := var_two := 0; --- Gives an error
ThanksMichaelS wrote:
Not always: Beware of CHAR's:
Bug 727361: ZERO-LENGTH STRING DOES NOT RETURN NULL WHEN USED WITH CHAR DATA TYPE IN PL/SQL:
SQL> declare
2 l_str1 char (10) := '';
3 l_str2 char (10) := null;
4 begin
5
6 if l_str1 is null
7 then
8 dbms_output.put_line ('oh STR1 is null');
9 elsif l_str1 is not null
10 then
11 dbms_output.put_line ('oh STR1 is NOT null');
12 end if;
13
14 if l_str2 is null
15 then
16 dbms_output.put_line ('oh STR2 is null');
17 elsif l_str2 is not null
18 then
19 dbms_output.put_line ('oh STR2 is NOT null');
20 end if;
21 end;
22 /
oh STR1 is NOT null
oh STR2 is null
PL/SQL procedure successfully completed.
SQL> alter session set events '10932 trace name context forever, level 16384';
Session altered.
SQL> declare
2 l_str1 char (10) := '';
3 l_str2 char (10) := null;
4 begin
5
6 if l_str1 is null
7 then
8 dbms_output.put_line ('oh STR1 is null');
9 elsif l_str1 is not null
10 then
11 dbms_output.put_line ('oh STR1 is NOT null');
12 end if;
13
14 if l_str2 is null
15 then
16 dbms_output.put_line ('oh STR2 is null');
17 elsif l_str2 is not null
18 then
19 dbms_output.put_line ('oh STR2 is NOT null');
20 end if;
21 end;
22 /
oh STR1 is null
oh STR2 is null
PL/SQL procedure successfully completed.
SQL> SY. -
Passing null/empty values from a actionscript VO to a Coldfusion ORM object
This is the situation.
If you have an actionscript VO that binds to a Coldfusion ORM object via the RemoteClass metadata and some of the values are not set, null, or empty strings and you pass it from Flex to Coldfusion then the Coldfusion deserialization barfs saying the values are not acceptable date values (for type="date") or valid emails (for validation="email") or other such validations, even if required="false" on the property.
For instance, if you have the following actionscript VO:
package vo
[RemoteClass(alias="com.companyname.Person")]
[Bindable]
public class Person
public var person_id:Number;
public var last_name:String;
public var first_name:String;
public var email:String;
public var created_date:date;
public function Person() {}
And you have the corresponding Coldfusion component:
<cfcomponent displayname="person" output="false"
alias="com.companyname.Person"
schema="dbo" persistent="true"
table="PERSON">
<cfproperty name="person_id" type="numeric" fieldtype="id" validate="integer" required="true" column="PERSON_ID"/>
<cfproperty name="last_name" type="string" column="LAST_NAME" required="true"/>
<cfproperty name="first_name" type="string" required="true" column="FIRST_NAME"/>
<cfproperty name="email" type="string" validate="email" required="false" column="EMAIL"/>
<cfproperty name="date_created" type="date" required="false" column="DATE_CREATED"/>
</cfcomponent>
Then if you pass the actionscript VO as is to Coldfusion, the deserialization complains that you do not have a valid email or a valid date for date_created. This is bad, bad, bad. Essentially if you have a validation of certain types (email being one) or a date property, or probably some other cases, then you essentially can not make it not required, it automatically makes it required because the Coldfusion serializer considers null/empty values as invalid dates or emails. But the serializer should not care for values that are not required, there has to be a way to pass null/empty values to these data types, but apparently there's not. If you pass an empty string ("") you still have the same problem. I know Coldfusion does not have null values, but there has to be a way to do this, otherwise it defeats the purpose of having required="false" and some kind of validation on the property.
There seems to be two ways around it. One is to override the implicit setters for the properties on the Coldfusion side and check for 0 length values yourself, then set the property if it is not, or create your own validation routine. I ended up creating my own validation function since I didn't want to have to write a setter function for everyone of these cases and I can pass back user friendly validation messages.
Have other people encountered this problem? How have you gotten around it? Thanks.I realize that I didn't clarify that I am using ColdFusion
for getting the data. This class was generated by the Create CFC
wizard in Flex Builder.
package com.generated
[Managed]
[RemoteClass(alias="components.generated.clients.Clients")]
public class Clients
public var clientid:Number = 0;
public var clientfirstname:String = "";
public var clientlastname:String = "";
public var clientaddress1:String = "";
public var clientaddress2:String = "";
public var clientcity:String = "";
public var clientstate:String = "";
public var clientzip:String = "";
public var clientphone:String = "";
public var clientemail:String = "";
public function Clients()
} -
Passing null/empty values from Flex to a Coldfusion ORM object
This is the situation.
If you have an actionscript VO that binds to a Coldfusion ORM object via the RemoteClass metadata and some of the values are not set, null, or empty strings and you pass it from Flex to Coldfusion then the Coldfusion deserialization barfs saying the values are not acceptable date values (for type="date") or valid emails (for validation="email") or other such validations, even if required="false" on the property.
For instance, if you have the following actionscript VO:
package vo
[RemoteClass(alias="com.companyname.Person")]
[Bindable]
public class Person
public var person_id:Number;
public var last_name:String;
public var first_name:String;
public var email:String;
public var created_date:date;
public function Person() {}
And you have the corresponding Coldfusion component:
<cfcomponent displayname="person" output="false"
alias="com.companyname.Person"
schema="dbo" persistent="true"
table="PERSON">
<cfproperty name="person_id" type="numeric" fieldtype="id" validate="integer" required="true" column="PERSON_ID"/>
<cfproperty name="last_name" type="string" column="LAST_NAME" required="true"/>
<cfproperty name="first_name" type="string" required="true" column="FIRST_NAME"/>
<cfproperty name="email" type="string" validate="email" required="false" column="EMAIL"/>
<cfproperty name="date_created" type="date" required="false" column="DATE_CREATED"/>
</cfcomponent>
Then if you pass the actionscript VO as is to Coldfusion, the deserialization complains that you do not have a valid email or a valid date for date_created. This is bad, bad, bad. Essentially if you have a validation of certain types (email being one) or a date property, or probably some other cases, then you essentially can not make it not required, it automatically makes it required because the Coldfusion serializer considers null/empty values as invalid dates or emails. But the serializer should not care for values that are not required, there has to be a way to pass null/empty values to these data types, but apparently there's not. If you pass an empty string ("") you still have the same problem. I know Coldfusion does not have null values, but there has to be a way to do this, otherwise it defeats the purpose of having required="false" and some kind of validation on the property.
There seems to be two ways around it. One is to override the implicit setters for the properties on the Coldfusion side and check for 0 length values yourself, then set the property if it is not, or create your own validation routine. I ended up creating my own validation function since I didn't want to have to write a setter function for everyone of these cases and I can pass back user friendly validation messages.
Have other people encountered this problem? How have you gotten around it? Thanks.Looks like a known workaround to this issue is to wrap the Flex object in an array.
The ColdFusion CFC will accept that as an array, with the first an only element being a struct, which is the object you built in Flex. -
Varchar2, empty strings and NULL
Hi all,
When inserting an empty string into a column of type varchar2 - is a NULL value stored in the column by the database? I've seen conflicting reports, and I know that the SQL 1992 spec specifies that empty strings not be treated as a NULL value, but that Oracle has traditionally treated zero length strings stored in a varchar2 column as NULL.
So, is there a way to store an empty string in a varchar2 column as an empty string and not a NULL value?
TIA,
SethIt can be even more complicated or annoying than NULL not equal to ASCII NULL.
example:
create table test_null
(fld1 varchar2(10),
fld2 varchar2(10),
fld3 varchar2(20));
insert into test_null values (chr(0),null, 'chr(0) and null');
insert into test_null values (null, null, 'null and null');
insert into test_null values ('', chr(0), ''''' and chr(0)');
insert into test_null values ('', null, ''''' and null');
select * from test_null;
FLD1 FLD2 FLD3
chr(0) and null
null and null
'' and chr(0)
'' and null
1 DECLARE
2 BEGIN
3 for c1 in (select fld1, fld2, fld3 from test_null) loop
4 if c1.fld1 = c1.fld2 then
5 dbms_output.put_line(c1.fld3||' Are equal'||
6 ' Length fld1 = '||to_char(length(c1.fld1))||
7 ' Length fld2 = '||to_char(length(c1.fld2)));
8 else
9 dbms_output.put_line(c1.fld3||' Are NOT equal'||
10 ' Length fld1 = '||to_char(length(c1.fld1))||
11 ' Length fld2 = '||to_char(length(c1.fld2)));
12 end if;
13 dbms_output.put_line(' ');
14 end loop;
15* END;
SQL> /
chr(0) and null Are NOT equal Length fld1 = 1 Length fld2 =
null and null Are NOT equal Length fld1 = Length fld2 =
'' and chr(0) Are NOT equal Length fld1 = Length fld2 = 1
'' and null Are NOT equal Length fld1 = Length fld2 =
PL/SQL procedure successfully completed. -
Data Object Fields on MI Client 7.1: Null value instead of empty value
Hi,
We are migrating an application from Mobile 7.0 to 7.1 and we don´t know if our Data Objects are missing some configuration, but when a field is sent to MI Client with empty (blank) value, we get this field in the application with a null value instead of an empty value.
This same application works fine in Mobile 7.0 and when a field with empty value is sent to MI Client, a empty value is get by the application.
Has anyone any idea?
Thanks.Hi,
SAP has solved the issue. They told us to add the following parameter in defaults.properties:
com.sap.tc.mobile.bc.string.trim=false
Thanks.
Maybe you are looking for
-
I got my mac pro in the middle of August. School started the week after. Internet was working perfectly fine at home. But at school, I never had a good connection. Sometimes on the good days I get a connection when I'm sitting at the exact spot in cl
-
Problem using email to upload image files to Mobile Me gallery
I will cross post this question to both Mail and Mobile Me discussion groups because I don't know where my problem lies. I have published a gallery page from iPhoto to my Mobile Me gallery. There are two ways to upload additional photos. I am not hav
-
TS1717 iTunes tends to freeze MacBook in many different ways?
Since I moved from Belgium to Australia following problem occurs: - When my Macbook Pro (OS X Lion 10.7.5) gets out of (screen)sleepmode when running music on iTunes the computer freezes and the song that was playing gets stuck on the last note. - Wh
-
I would like to create a pdf document from several photos - is there a limit and how do i do that please?
-
Is it possible to install/use WhatsApp in iPod touch 5th generation?
Hey Guys!! I am much curious on Apple products and I wanna own one for me. So I planned to buy an iPhone 6 and as it's quite costlier for my current financial situation, I changed my mind. I wanna buy any product from Apple, and now I am finalizing w