|
You need to handle the exception and then display your customize message box as your requirement.
take a look there[^] for getting more details about Exception.
|
|
|
|
|
i have this particular line in my program however when i execute this line it gives me error.
Integer addIncidentID = (Integer) getIncidentidtxt().getValue();
how do i convert from string to integer?
|
|
|
|
|
Of course you can't cast a String to an Integer, they are two completely unrelated types. You have to use the Integer.valueOff(String s) method:
Integer addIncidentID = Integer.valueOff(getIncidentidtxt().getValue());
|
|
|
|
|
// to primitive int i from Integer Object ii
int i = ii.intValue();
// to Integer ii from primitive int i
Integer ii = new Integer( i );
|
|
|
|
|
this is a static method of the type Integer:
int iValue = Integer.parseInt(givenString);
This one throws an exception when converting fails. So best is to wrap in a try/catch:
int iValue=0;
try{
iValue = Integer.parseInt(givenString);
}
catch(NumberFormatException oException){
}
regards,
Torsten
I never finish anyth...
|
|
|
|
|
can i use interger.parseint?
|
|
|
|
|
that's kind of the one I mentioned - if "interger" is just a typo and is supposed to be "Integer".
see post above your post.
regards
Torsten
I never finish anyth...
|
|
|
|
|
Please, check the javadoc !
Yes you can use parseInt but it returns an int, not an Integer. So, depending on your needs, either use valueOf or parseInt.
|
|
|
|
|
pancakeleh wrote:
how do i convert from string to integer?
you can convert string to integer by using various ways
you can use valueOf method of Integer class in this way
Integer obj = Integer.valueOf(str_value);
you can use Integer Constructor
Integer obj = new Integer(str_value);
you can use parseInt method
int objt = Integer.parseInt(str_value);
for more details move there[^]
|
|
|
|
|
For Example:
String abc123 = "123";
Integer abcint = Integer.valueOf(abc123);
|
|
|
|
|
|
int int_page_id=o;
String str_page_id="5";
try {
int_page_id = Integer.parseInt(str_page_id);
} catch(NumberFormatException ex) {
ex.printStackTrace();
}
|
|
|
|
|
String a="2";
int value = Integer.parseInt(a);
|
|
|
|
|
Hey!
I need to save some properties encrypted. So I have a key and a value, which I should separate in some way with some character or symbol. The most used "=" is used in Base64 encoding and will not work.
Which characters or symbols or totally strange hieroglyphs are not used in Base64 encoding?
How can guarantee access to the properties
Anyone ever played that game?
regards
Torsten
I never finish anyth...
|
|
|
|
|
TorstenH. wrote: So I have a key and a value, which I should separate in some way with some character or symbol. The most used "=" is used in Base64 encoding and will not work.
You should be able to convert the string "bla=1" to Base64 and back, regardless of the equal-sign within that string. Did it fail, and if so, what error did it generate?
I are Troll
|
|
|
|
|
sometimes its simpler than expected. Have I thought of doing it this way?
You're right, I could convert the complete string. Right now I'm just converting the value - this looks like "label.text=qwertzwtf==". This has the opportunity of deleting certain entries when needed. The values are not predefined, admin users (our crew) are able to add additional entries by using a dialog. Simple users (customers) should not be able to manipulate out those values(safety reasons).
I figured out (try&error) that the "@"-symbol is pretty safe, so I changed my properties to "label.text@qwertzwtf==". works like a charm so far
regards,
Torsten
I never finish anyth...
|
|
|
|
|
TorstenH. wrote: The values are not predefined, admin users (our crew) are able to add additional entries by using a dialog. Simple users (customers) should not be able to manipulate out those values(safety reasons).
Sounds like a convenient solution to a common problem
I are Troll
|
|
|
|
|
just the regular magic... I 'll leave it to the "@" and wait for the QC department to find out if it works
regards,
Torsten
I never finish anyth...
|
|
|
|
|
TorstenH. wrote: I could convert the complete string
why would you? the first equal sign would be your separator, what is to the left of it would be the key (the name), what is to the right of it the base64-encoded value.
the advantage is the structure of your file remains intelligible.
|
|
|
|
|
|
cool. thanks.
This gives me the certainty to have done it right and to have a safe functionality
regards,
Torsten
I never finish anyth...
|
|
|
|
|
|
|
oh update object meaning? so sorry for asking cos i am very new and still dunno much. This also occurs when the delete button is being clicked.
my code as shown below:
public String incidentDel_btn_action() {<br />
<br />
form1.discardSubmittedValues("addIncidentStatus");<br />
<br />
try {<br />
RowKey rk = tableRowGroup2.getRowKey();<br />
if (rk != null) {<br />
incidentstatusDataProvider.removeRow(rk);<br />
incidentstatusDataProvider.commitChanges();<br />
incidentstatusDataProvider.refresh();<br />
}<br />
}<br />
catch (Exception ex) {<br />
log("ErrorDescription", ex);<br />
error(ex.getMessage());<br />
}<br />
return null;<br />
}
modified on Thursday, December 23, 2010 3:26 AM
|
|
|
|
|
Hello i come across this problem when i am trying to delete info from my database.
Screenshot here: ""[^]
any solution?
|
|
|
|