on 11-20-2008 12:51 AM
Hi,
I'm having an input field. if user enters blank space over there and tries to save it, i need an exception.
i need taa validation for that. how to validate for empty spaces on click of an action
Thanks & Regards,
Suresh
if your input field is binded to attribute under nodexxxx then follow this code:
IWDMessageManager msgMan = wdControllerAPI.getComponent().getMessageManager();
// Get field value of attribute under investigation
String value = wdContext.node<xxx>.currentxxxElement().getAttributeAsText(fieldname);
// Check if any input is provided
if (value.length() == 0) {
// if not: report error, which is related to context attribute under investigation
msgMan.reportContextAttributeMessage(
wdContext.nodexxx().currentxxxElement(),Attr,
IMessageEx7Comp.MISSING_INPUT,new Object[] { fieldname },true);
}
here MissingInput is the error defined in message pool of componenet to display "Entry of a valid is required for proceeding." when no input is given for the input field.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi
If you want to validate value only on some action, you must write validation code into action handler:
final String value = wdContext.current<your node>().get<your attribute>();
if (value.trim().length() == 0) {
wdComponentAPI.wdGetMessageManager().reportInvalidContextAttributeException(
wdContext.current<your node>(),
wdContext.node<your node>().getNodeInfo().getAttribute("<your attribute name">),
"<message about wrong value>",
true);
}
But if you want to use WD validation mechanisms, set corresponding ISimpleValueServices instance for your attribute simple type.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Inside the action try this.
String Input=wdContext.current<node>Element().get<inputfield>();
if(Input== null || Input== "" || Input== " " || Input.trim().equalsIgnoreCase("")){
wdComponentAPI.getMessageManager().raiseException("Please Enter the Value.",false);
}
Hope this helps!!!!!
-Swati
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Use the given code
if(wdContext.currentContextElement.get<InputFieldVal>.equals(""))
{
wdComponentAPI.getMessageManager().reportException("Message",false);
}
Regards,
Padma N
|
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
You can do the required validation as:
if(null == wdContext.current<ur_node>element().getIpFld() || wdContext.current<ur_node>element().getIpFld().trim().equals(""))
{
//. . . Raise exception or render error message
wdComponetAPI.getMeassageManager().reportexception("Your Error Message",false);
}
else
{
//. . . Continue processing
}
Regards,
Alka.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
you cant use a trim function as trim() is a compare type function. Means it works if and if there is atleast on character in the string...
String s="test ";
now s.trim() works but if
String ss=" ";
now ss.trim() will not work...
and if
String strst=" ";
then
if(strss==null) will also not wok, as string has a space characte inside it...
Regards,
Srinivas
User | Count |
---|---|
90 | |
10 | |
10 | |
10 | |
7 | |
7 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.