How to do number validation on String
Hi,
I need to validate value like
String object=valueChangeEvent.getNewValue().toString();
Integer in=Integer.parseInt(object);
if(in>=50000){
FacesContext fctx = FacesContext.getCurrentInstance();
FacesMessage message =
new FacesMessage("The Authorization Amount you entered is $50,000 or more. Please confirm the amount entered");
message.setSeverity(FacesMessage.SEVERITY_WARN);
fctx.addMessage(null, message);
but here i am getting error when value as 54,99 or 54.99 i am getting error like number format exception how can achive this.
If the number can have a decimal part in the UI you should use Double.parseDouble(object); and then do your validation. An integer can't have a decimal part so you get the number format error.
Timo
Similar Messages
-
How can I perform validation of String withing TableCell to get red outline
I have two columns in a JTable, one is defined to be an Integer and one as a String, when they edit the Integer field add enter an non-integral value the DefaultCellEditor outlines the cell in red and prevents them leaving the cell until they have either entered a valid value or cancel the operation (by pressing 'Esc' on Windows).
Where is this behaviour I cant find it in the Java source code, I want to replicate it for a String to do the same thing if the String does not match a regular expression. I have tried subclassing DefaultCellEditor, and and passing an InputVerifier to the text component used to in the construction of the editor degate, but this has had no effect. I also tried overiding stopCellEditing() this had the effect of preventing leaving the cell until they have entered a correct value, but it does not outline it in red
public class ExcelRefCellEditor extends DefaultCellEditor
public ExcelRefCellEditor(JTextField textfield)
//@TODO seems to have no effect
super(textfield);
textfield.setInputVerifier(new ExcelRefInputVerifier());
public boolean stopCellEditing()
if(!AQExcelRef.isValidForm((String)delegate.getCellEditorValue()))
return false;
else
return delegate.stopCellEditing();
class ExcelRefInputVerifier extends InputVerifier
public boolean verify(JComponent input)
return AQExcelRef.isValidForm(((JTextField)input).getText());
class AQExcelRef implements Serializable
public static boolean isValidForm(String cellRef)
return cellRef.matches("[A-Z]+[1-9]+");
tc.setCellEditor(new ExcelRefCellEditor(new JTextField()));Thanks that works perfectly
But I would be interested to know how it it is done for Integer columns as I cant find any code to do this in the DefaultCellEditor, and I took a quick look at the plaf packages and suns internal packages as well. -
How to find number from text string??
Hi All,
Can you tell me how to find/ fetch number from string?
is there any function module for this.?
for example , I have string like "+++++1000000589+++"
and I need to fetch the invoice no 1000000589 from the above string..then How to do that? Letters may come first or number may come first and latter text...
Regards,
MrunalYou can do like this.
The below mentioned is code separate material
DO 18 TIMES.
LV_C = LV_C + 1.
LV_C1 = LV_C - 1.
IF GW_MATNR-MATNR+LV_C1(1) CN '0,1,2,3,4,5,6,7,8,9' .
IF ( ( LV_MAT EQ SPACE ) ) ." and ( lv_prefix eq space ) ) .
LV_PREFIX = 'X'.
CONCATENATE GW_TEMP-PREFIX GW_MATNR-MATNR+LV_C1(1) INTO
GW_TEMP-PREFIX.
ELSE.
LV_SUFFIX = 'X'.
CONCATENATE GW_TEMP-SUFFIX GW_MATNR-MATNR+LV_C1(1) INTO
GW_TEMP-SUFFIX.
ENDIF.
ELSEIF ( ( LV_SUFFIX EQ SPACE ) ) .
LV_MAT = 'X'.
CONCATENATE GW_TEMP-MATNR1 GW_MATNR-MATNR+LV_C1(1) INTO
GW_TEMP-MATNR1.
ELSEIF ( ( LV_MAT EQ 'X' ) ) .
CONCATENATE GW_TEMP-SUFFIX GW_MATNR-MATNR+LV_C1(1) INTO
GW_TEMP-SUFFIX.
ENDIF.
ENDDO. -
How to Plot number and string in one row (data logger counter) ?
hi all i made data log quantity using Digital Counter via modbus to monitoring quantity and reject that has and Name Operator, Machine and Part Number.
i have problem about plot the number & string in one row, as shown on the picture below :
how to move that string on one row ? i attach my vi.
Thanks~
Attachments:
MODBUS LIB Counter.vi 39 KBDuplicate and answered - http://forums.ni.com/t5/LabVIEW/How-to-Plot-number-and-string-in-one-row-data-logger-counter-via/m-p...
-
How to config Check Digits function module for Student Number Validation
Hi SLCM Experts,
In the SAP-SLCM, How to use check digits function module for validate student number. Just only config it or need to customizing program.
*Any idea to student number validation in SLCM?*
Best Regards,
Suvatchai K.Hi ,
Can you expalin it further ?
You configure the St. no in piq_matr . And set it as external or internal no. range which suits your business .
What is the validation you are looking for ?
Regards
Gajalakshmi -
How to use type cast change string to number(dbl)?can it work?
how to use type cast change string to number(dbl)?can it work?
Do you want to Type Cast (function in the Advanced >> Data Manipulation palette) or Convert (functions in the String >> String/Number Conversion palette)?
2 simple examples:
"1" cast as I8 = 49 or 31 hex.
"1" converted to decimal = 1.
"20" cast as I16 = 12848 or 3230 hex.
"20" converted to decimal = 20.
Note that type casting a string to an integer results in a byte by byte conversion to the ASCII values.
32 hex is an ASCII "2" and 30 hex is an ASCII "0" so "20" cast as I16 becomes 3230 hex.
When type casting a string to a double, the string must conform the the IEEE 32 bit floating point representation, which is typically not easy to enter from the keyboard.
See tha attached LabView 6.1 example.
Attachments:
TypeCastAndConvert.vi 34 KB -
How do one validate Photoshop 13. (Windows 8) Upon activation, get through to sign in screen, but when doing serial number validation, validate goes round but does not validate. Connect Later is only way out of screen. Checked account but product not listed. Installed with serial number that was sent by Adobe. Have attempted numerous times at different times of the day. On-line connection working.
Have you bothered to do any research at all? Not every app was upgrade to 5.5. Those that weren’t will next be upgraded to CS6.
Bob -
How to generate a unique 8 byte number for a String in DES
Hi All,
Is there any way to generate a unique 8 byte number representation of String?
I know it can be done with DES encryption (while MD5 gives 16 bytes number). My requirement is:
Every time a String is passed - my static method should return the same unique number - all the time.
i.e A String "AAAAAA" will return same unique number all the time. How can I achieve this (8 byte number) by DES Encryption or any other encryption?
Thanking all in advance.Thanks for your reply. Won't there be any loss of data if I consider only first 8 bytes? Will Integrity be maintained.?
In some cases my Strings can be unusually long - having length of 400 to 500.
I want 8 bytes as I want to map the number with MySQL bigint field. -
Hql how to cast number to varchar2
Hello.
How to cast number to varchar2(to string)? I'm using hql toplink implementation and (don't know why) functions like cast(... as ...), to_char(...) and str(...) don't work. Please help me.
Kuba :).
Edited by: 854998 on 2011-04-27 03:12Hello Chris.
First of all I'd like to thank you for answer. :)
1)I can't use native query.
2)What do you mean?
3)I can't upgrade.
I have something like this(it's only simple example, I have more complex query):
getManager().createQuery("SELECT obj FROM " + EntityClass.class.getSimpleName() + " obj "
+ " WHERE '14' = obj.number").getResultList();
r.number is Number in Oracle and Long in entity class.
I want to cast obj.number to String.
Here: http://docs.jboss.org/hibernate/core/3.3/reference/en/html/queryhql.html#queryhql-expressions expressions like cast is valid.
So, where's the problem? My toplink version is too old?
Thanks a lot
Kuba. -
How do I process serial port strings as bits
In response to my commands, my instrument is sending bytes to my serial
port. In one instance, 2 bytes are received. I want to treat these 2 bytes
as a group of 16 bits.
The VISA and Compatibility Serial functions return these bytes from the
serial port to Labview clearly labelled a "string".
Everything I can find in the way of Labview functions and .vis don't want to
do bit twiddling, bit swapping, and bit dropping, with "string" data.
I thought "hex string to number" could be used here, but I can't find a way.
The 2 Bytes in question can be represented as hex, but the data are not the
ASCII codes for the hex representation of a binary number, they are the
binary number. This "hex string to number" seems to want ASCII c
odes.
You can feed a hex number typed into a "control" box wired into "hex string
to number" and you get a meaningful number. You can feed the 2 bytes from
the serial port into an "indicator" set to read in hex and you get a hex
number that is a correct representation. But that is Labview handing them
around to itself. I need to get my "hands" on them.
I can't feed those same bytes that show up as a correct hex representation
in an indicator into the "hex string to number" or anything else, so far,
and get a number that is useful for further processing.
I thought "variant to data", but I can't find enough reference material to
understand how to use it. A boolean array seems like a bit of a weird
approach, so I thought I'd ask before I looked into that.
I'm used to dealing directly with binary numbers on the processor stack, I
call them whatever I want, and turn them into anything I feel like.
I'm sure I'm staring the solution in the face, but I can't find any way to
persuade
Labview to treat this "string" data as 16 bits.
I've got the 16 bits, which is better than not having them, but I don't have
much hair left.duh, well I finally discovered the "Unflatten from String" function. A guy
just feeds in the bytes he's collected from his serial port that Labview
thinks are a "string", and out come lovely little unsigned 16 bit numbers,
or whatever other type of number he wants to turn the bytes into. And there
are great little bit twiddlers available after that, like "swap bytes", and
you can mask out bits with the logic operators, why this is fun. There's
nothing like being a moron...... fly me to the moon...................
"David Lewis" wrote in message
news:[email protected]..
> The two bytes would come from a serial port read.vi in Labview, classed as
a
> string. For instance, D3 and 02. The output wou
ld swap the two bytes,
i.e.
> to 02 and D3, consider the two swapped bytes as 16 bits, drop the six most
> significant bits, and output the ten bits that are left as an integer
> classed by Labview as some kind of number, not a string.
>
> Your example StringToBits_Converter.vi I found on the ni.com site
> unfortunately gives an error message and refuses to open on my system
saying
> it comes from a newer version of Labview 6 than I am running. Mine says
> 6.0.1b3. Thank you very much anyway.
>
> "FightOnSCTrojan" wrote in message
> news:[email protected]..
> > In another words, you want to create a VI in which the input is 2
> > strings (i.e. AB) and the output is the converted array bits (e.g.
> > 1010101010101010)?
>
> -
How to get number of rows return in SELECT query
i'm very new in java, i have a question:
- How to get number of rows return in SELECT query?
(i use SQL Server 2000 Driver for JDBC and everything are done, i only want to know problems above)
Thanks.make the result set scroll insensitve, do rs.last(), get the row num, and call rs.beforeFirst(), then you can process the result set like you currently do.
String sql = "select * from testing";
PreparedStatement ps =
con.prepareStatement(sql,ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);
ResultSet rs = ps.executeQuery();
rs.last();
System.out.println("Row count = " + rs.getRow());
rs.beforeFirst();~Tim
NOTE: Ugly, but does the trick. -
How to delete number (00) in a SQL Server column ?
how to delete number (00) in a SQL Server column ?
example :
column : Births before Births
after
199900
1999
198200
1982
200400
2004
help queryYou use REPLACE function to selectively replace text inside a string in SQL Server. The REPLACE function is easy to use and very handy with an UPDATE statement.
SELECT Replace(births, '00', '')
or
update .....
Also you can use STUFF()
This function can be used for delete a certain length of the string and insert a new string in the deleted place.
Select STUFF ('199900', 5, 2, '')
--result 1900,1982,....
Ahsan Kabir Please remember to click Mark as Answer and Vote as Helpful on posts that help you. This can be beneficial to other community members reading the thread. http://www.aktechforum.blogspot.com/ -
How Can I replace newScale Text Strings with Custom Values?
How Can I replace newScale Text Strings with Custom Values?
How can I replace newScale text strings with custom values?
All newScale text is customizable. Follow the procedure below to change the value of any text string that appears in RequestCenter online pages.
Procedure
1. Find out the String ID of the text string you would like to overwrite by turning on the String ID display:
a) Navigate to the RequestCenter.ear/config directory.
b) Open the newscale.properties file and add the following name-value pair at the end of the file:res.format=2
c) Save the file.
d) Repeat steps b and c for the RmiConfig.prop and RequestCenter.prop files.
e) Stop and restart the RequestCenter service.
f) Log in to RequestCenter and browse to the page that has the text you want to overwrite. In front of the text you will now see the String ID.
g) Note down the String ID's you want to change.
2. Navigate to the directory: /RequestCenter.ear/RequestCenter.war/WEB-INF/classes/com/newscale/bfw.
3. Create the following sub-directory: res/resources
4. Create the following empty text files in the directory you just created:
RequestCenter_0.properties
RequestCenter_1.properties
RequestCenter_2.properties
RequestCenter_3.properties
RequestCenter_4.properties
RequestCenter_5.properties
RequestCenter_6.properties
RequestCenter_7.properties
5. Add the custom text strings to the appropriate RequestCenter_<Number>.properties file in the following manner (name-value pair) StringID=YourCustomTextString
Example: The StringID for "Available Work" in ServiceManager is 699.
If you wanted to change "Available Work" to "General Inbox", you would add the following line to the RequestCenter_0.properties file
699=General Inbox
Strings are divided into the following files, based on their numeric ID:
Strings are divided into the following files, based on their numeric ID:
String ID File Name
0 to 999 -> RequestCenter_0.properties
1000 to 1999 -> RequestCenter_1.properties
2000 to 2999 -> RequestCenter_2.properties
3000 to 3999 -> RequestCenter_3.properties
4000 to 4999 -> RequestCenter_4.properties
5000 to 5999 -> RequestCenter_5.properties
6000 to 6999 -> RequestCenter_6.properties
7000 to 7999 -> RequestCenter_7.properties
6. Turn off the String ID display by removing (or commenting out) the line "res.format=2" from the newscale.properties, RequestCenter.prop and RmiConfig.prop files
7. Restart RequestCenter.
Your customized text should be displayed.I've recently come across this information and it was very helpful in changing some of the inline text.
However, one place that seemed out of reach with this method was the three main buttons on an "Order" page. Specifically the "Add & Review Order" button was confusing some of our users.
Through the use of JavaScript we were able to modify the label of this button. We placed JS in the footer.html file that changes the value of the butt -
How to find number of files in a folder using pl/sql
please someone guide as to how to find number of files in a folder using pl/sql
RegardsThe Java option works well.
-- results table that will contain a file list result
create global temporary table directory_list
directory varchar2(1000),
filename varchar2(1000)
on commit preserve rows
-- allowing public access to this temp table
grant select, update, insert, delete on directory_list to public;
create or replace public synonym directory_list for directory_list;
-- creating the java proc that does the file listing
create or replace and compile java source named "ListFiles" as
import java.io.*;
import java.sql.*;
public class ListFiles
public static void getList(String directory, String filter)
throws SQLException
File path = new File( directory );
final String ExpressionFilter = filter;
FilenameFilter fileFilter = new FilenameFilter() {
public boolean accept(File dir, String name) {
if(name.equalsIgnoreCase(ExpressionFilter))
return true;
if(name.matches("." + ExpressionFilter))
return true;
return false;
String[] list = path.list(fileFilter);
String element;
for(int i = 0; i < list.length; i++)
element = list;
#sql {
insert
into directory_list
( directory, filename )
values
( :directory, :element )
-- creating the PL/SQL wrapper for the java proc
create or replace procedure ListFiles( cDirectory in varchar2, cFilter in varchar2 )
as language java
name 'ListFiles.getList( java.lang.String, java.lang.String )';
-- punching a hole in the Java VM that allows access to the server's file
-- systems from inside the Oracle JVM (these also allows executing command
-- line and external programs)
-- NOTE: this hole MUST be secured using proper Oracle security (e.g. AUTHID
-- DEFINER PL/SQL code that is trusted)
declare
SCHEMA varchar2(30) := USER;
begin
dbms_java.grant_permission(
SCHEMA,
'SYS:java.io.FilePermission',
'<<ALL FILES>>',
'execute, read, write, delete'
dbms_java.grant_permission(
SCHEMA,
'SYS:java.lang.RuntimePermission',
'writeFileDescriptor',
dbms_java.grant_permission(
SCHEMA,
'SYS:java.lang.RuntimePermission',
'readFileDescriptor',
commit;
end;
To use:
SQL> exec ListFiles('/tmp', '*.log' );
PL/SQL procedure successfully completed.
SQL> select * from directory_list;
DIRECTORY FILENAME
/tmp X11_newfonts.log
/tmp ipv6agt.crashlog
/tmp dtappint.log
/tmp Core.sd-log
/tmp core_intg.sd-log
/tmp da.sd-log
/tmp dhcpclient.log
/tmp oracle8.sd-log
/tmp cc.sd-log
/tmp oms.log
/tmp OmniBack.sd-log
/tmp DPISInstall.sd-log
12 rows selected.
SQL> -
How to do the Validations in Report Programming?
How to do the Validations in Report Programming?
how to do screen Validations and Field Validations if posssible can any one send the code regarding the Validation ....
Tks
DurusojuAT SELECTION-SCREEN - selscreen_event
Syntax
| { ON {para|selcrit} }
| { ON END OF selcrit }
| { ON BLOCK block }
| { ON RADIOBUTTON GROUP radi }
| { }
| { ON {HELP-REQUEST|VALUE-REQUEST}
| FOR {para|selcrit-low|selcrit-high} }
| { ON EXIT-COMMAND }.
Alternatives:
1. ... OUTPUT
2. ... ON {para|selcrit}
3. ... ON END OF selcrit
4. ... ON BLOCK block
5. ... ON RADIOBUTTON GROUP radi
6. ... { }
7. ... ON {HELP-REQUEST|VALUE-REQUEST} FOR
{para|selcrit-low|selcrit-high} }
8. ... ON EXIT-COMMAND
Effect
These additions allow individual evaluation of specific elements of the selection screens of the program. The information as to which selection has triggered the event is contained in the system field sy-dynnr.
Alternative 1
... OUTPUT
Effect
This event is triggered at the screen event PBO of a selection screen. In the event block, the selection screen can be prepared through assignments to the data objects of parameters and selection criteria and through dynamic screen modifications.
Note
The assignments to input fields in the event block AT SELECTION-SCREEN OUTPUT always affect the selection screen and overwrite the user inputs from previous displays of the same selection screen. Assignments in the event blocks LOAD-OF-PROGRAM oder INITIALIZATION, on the other hand, only have an effect at first program start.
Alternative 2
... ON {para|selcrit}
Effect
This event is triggered at the screen event PAI of a selection screen if the content of the input field of a parameter para or a line of a selection criterion selcrit was passed to the ABAP program. In the event block, the user input can be checked. Sending a warning or an error message in the event block makes the fields para and selcrit ready for input again.
No parameter that is defined as a radio button can be specified. For this purpose, the addition ON RADIOBUTTON GROUP is provided.
Note
If a user action takes place in the dialog box for the multiple selection of a selection criterion selcrit, the entries of the selection table are passed to the program, line by line. For each line, the event AT SELECTION-SCREEN ON selcrit is triggered.
Alternative 3
... ON END OF selcrit
Effect
This event is triggered after the selection table selcrit has been fully passed to the program after a user action in the dialog box for the multiple selection has taken place. In the event block, the entire selection table can be checked.
Alternative 4
... ON BLOCK block
Effect
This event is triggered at the screen event PAI of a selection screen if all the input fields of a block block of the selection screen were passed to the ABAP program. In the event block, the user inputs can be checked. Sending a warning or an error message in the event block makes all the fields of the block block ready for input again.
Alternative 5
... ON RADIOBUTTON GROUP radi
Effect
This event is triggered at the screen event PAI of a selection screen if all the fields of a radio button group radi of the selection screen were passed to the ABAP program. In the event block, the user input can be checked. Sending a warning or error message in the event block makes all the radion buttons of the block radi ready for input again.
Note
The individual fields of a radio button group are not passed individually and do not trigger the event AT SELECTION-SCREEN ON par.
Alternative 6
Effect
The event AT SELECTION-SCREEN itself is triggered as the last event of selection screen processing if all the input values were passed to the program. In this event block, all the user inputs can be checked. Sending a warning or an error message in the event block makes all the screen fields ready for input once again.
Alternative 7
... ON { HELP-REQUEST | VALUE-REQUEST } FOR
{para|selcrit-low|selcrit-high} }
Effect
The two events ON HELP-REQUEST and ON VALUE-REQUEST are triggered at the screen events POH and POV of a selection screen if - for the input field of a parameter para or one of the input fields of a selection criterion selcrit - the field help F1 or the input help F4 was called. Other selection events are not triggered.
In the event blocks, a self-defined field or input field can be programmed, which overrides any helps possibly defined in the ABAP Dictionary.
Notes
These event blocks can only be implemented for fields of the selection screen that are defined in the same ABAP program and not in a possibly linked logical database.
With the events for the field and input help, no data is transported between the selection screen and the ABAP program. As with general screens, suitable function modules must be used for these. The parameters and selection criteria changed for the input help are transported to the selection screen.
Alternative 8
... ON EXIT-COMMAND
Effect
This event is triggered if the user has called one of the functions Back, Exit or Cancel. In the event block, possible clean-up actions can be executed.
Example
In these executable programs, a standard selection screen and a further selection screen are defined. In the event blocks AT SELECTION-SCREEN, the inputs in the selection screens can be specially handled using the name p_carrid and the screen number in sy-dynnr.
REPORT demo_at_selection_screen.
Global data
DATA: sflight_tab TYPE TABLE OF sflight,
sflight_wa LIKE LINE OF sflight_tab.
Selection screens
PARAMETERS p_carrid TYPE spfli-carrid.
SELECTION-SCREEN BEGIN OF SCREEN 500.
SELECT-OPTIONS s_conn FOR sflight_wa-connid.
DATA s_conn_wa LIKE LINE OF s_conn.
SELECTION-SCREEN END OF SCREEN 500.
Handling selection screen events
AT SELECTION-SCREEN ON p_carrid.
IF p_carrid IS INITIAL.
MESSAGE 'Please enter a value' TYPE 'E'.
ENDIF.
AUTHORITY-CHECK OBJECT 'S_CARRID'
ID 'CARRID' FIELD p_carrid
ID 'ACTVT' FIELD '03'.
IF sy-subrc = 4.
MESSAGE 'No authorization for carrier' TYPE 'E'.
ELSEIF sy-subrc <> 0.
MESSAGE 'Error in authority check' TYPE 'A'.
ELSE.
IF sy-ucomm = 'ONLI'.
CALL SELECTION-SCREEN '0500'.
ENDIF.
ENDIF.
AT SELECTION-SCREEN.
IF sy-dynnr = '0500'.
IF s_conn IS INITIAL.
MESSAGE 'Please enter values' TYPE 'W'.
ELSE.
SELECT *
FROM sflight
INTO TABLE sflight_tab
WHERE carrid = p_carrid AND
connid IN s_conn.
IF sy-subrc <> 0.
MESSAGE 'No flights found' TYPE 'E'.
ENDIF.
ENDIF.
ENDIF.
Main program
START-OF-SELECTION.
Maybe you are looking for
-
Unable to see windows media player DLNA server
Hello, I thought it might be a result of my router. But upon further testing it appears to be an issue between the wireless portion of the router and the wired portion of the router. It does this with the old ActionTec with the Silver band as well. C
-
Error code 50 when updating desktop
I received error code 50 when updating the creative cloud dekstop. It tells me to contact customer support. how do i do that?
-
Mac OS 10.4.11 & X11user.pkg
Hi, I got a big problem to runnig new software on my mac. I am using a MacOS 10.4.11 and I need the X11user.pkg to run different software. X11 version 1.1 is installed on my mac, and on the mac os x install disc 1 there is only the x11 version 1.1 to
-
Exception in XMLIsValid function
Hi anybody can you help me in providing the actual error whic i am geetiing while validating the xml with xsd by using XMLIsValid function
-
Quick question about using iPhone before activation
Hi, I'm wondering if the iphone's other capabilities are usable even prior to activation. For example, before I activate my service, can I use it as an iPod? I'm asking because my friend bought one and it seems to give him no other choices but to act