Entity validation with groovy expression

Hi,
I'm using jdeveloper 11.1.2.3.0
I have an entity object with two attributes "status" and "reason".
Only in case the user select status id "4" I would like to validate that he will select also reason.
for this I was trying to add entity validation with groovy expression.
so I added this expression "Status== 4 && Reason == null" and also I added failure message.
But it doesn't work as I expected.
The error is displayed every time, also when the user select status that is not 4 and also when he select status 4 and the reason is not null.
How should I write this groovy expression?
Thanks

Just to clarify,
If you add this validation to your status attribute then it will validate that Reason is not null when you change the status to 4.
If you want to raise an entity validation just add a new Entity Validator and the expression should be something like what you had:
But slightly different
Status != null ? (Status==4? (Reason!=null) : true) : true

Similar Messages

  • CFFORM (Flash) Validation with Regular Expressions Not Working

    I am having troubles getting regular expression validation to
    work in a CFFORM. The below code is an extract of a much larger
    form, the first name and last name have a regular expression
    validation...and it doesn't work!
    I'd appreciate any comments/info for help on this, have
    searched high and low on information to get this working...but no
    joy.
    The code is:
    <cffunction name="checkFieldSet" output="false"
    returnType="string">
    <cfargument name="fields" type="string" required="true"
    hint="Fields to search">
    <cfargument name="form" type="string" required="true"
    hint="Name of the form">
    <cfargument name="ascode" type="string" required="true"
    hint="Code to fire if all is good.">
    <cfset var vcode = "">
    <cfset var f = "">
    <cfsavecontent variable="vcode">
    var ok = true;
    var msg = "";
    <cfloop index="f" list="#arguments.fields#">
    <cfoutput>
    if(!mx.validators.Validator.isValid(this,
    '#arguments.form#.#f#')) { msg = msg + #f#.errorString + '\n';
    ok=false; }
    </cfoutput>
    </cfloop>
    </cfsavecontent>
    <cfset vcode = vcode & "if(!ok)
    mx.controls.Alert.show(msg,'Validation Error'); ">
    <cfset vcode = vcode & "if(ok) #ascode#">
    <cfset vcode =
    replaceList(vcode,"#chr(10)#,#chr(13)#,#chr(9)#",",,")>
    <cfreturn vcode>
    </cffunction>
    <cfform name="new_form" format="flash" width="600"
    height="600" skin="halosilver" action="new_data.cfc">
    <cfformgroup type="panel" label="New Form"
    style="background-color:##CCCCCC;">
    <cfformgroup type="tabnavigator" id="tabs">
    <cfformgroup type="page" label="Step 1">
    <cfformgroup type="hbox">
    <cfformgroup type="panel" label="Requestor Information"
    style="headerHeight: 13;">
    <cfformgroup type="vbox">
    <cfinput type="text" name="reqName" width="300"
    label="First Name:" validate="regular_expression" pattern="[^0-9]"
    validateat="onblur" required="yes" message="You must supply your
    First Name.">
    <cfinput type="text" name="reqLname" width="300"
    label="Last Name:" validate="regular_expression" pattern="[^0-9]"
    validateat="onblur" required="yes" message="You must supply your
    Last Name.">
    <cfinput type="text" name="reqEmail" width="300"
    label="Email:" validate="email" required="yes" message="You must
    supply your email or the address given is in the wrong format.">
    <cfinput type="text" name="reqPhone" width="300"
    label="Phone Extension:" validate="integer" required="yes"
    maxlength="4" message="You must supply your phone number.">
    </cfformgroup>
    </cfformgroup>
    </cfformgroup>
    <cfformgroup type="horizontal"
    style="horizontalAlign:'right';">
    <cfinput type="button" width="100" name="cnt_step2"
    label="next" value="Next"
    onClick="#checkFieldSet("reqName,reqLname,reqEmail,reqPhone","new_form","tabs.selectedInd ex=tabs.selectedIndex+1")#"
    align="right">
    </cfformgroup>
    </cfformgroup>
    </cfformgroup>
    </cfformgroup>
    </cfform>

    quote:
    Originally posted by:
    Luckbox72
    The problem is not the Regex. I have tested 3 or 4 different
    versions that all work on the many different test sites. The
    problem is it that the validation does not seem to work. I have
    changed the patter to only allow NA and I can still type anything
    into the text box. Is there some issue with useing Regex as your
    validation?
    Bear in mind that by default validation does not occur until
    the user attempts to submit the form. If you are trying to control
    the characters that the user can enter into the textbox, as opposed
    to validating what they have entered, you will need to provide your
    own javascript validation.

  • Installing ODAC Entity Framework with oracle express

    Hi, I need to develop a .net web app with oracle back end. To setup development env. for oracle I downloaded oracle database express edition 11g 2. and installed it succesfully. after I tried to install this ODAC it throws me a error
    "Remove all the spaces from the chosen ORACLE_HOME" help me out to resolve this,
    Can I use SQL Developer to connect to Oracle Express. Kindly help me out asap.

    Hello,
    This is by designed in Entity Framework, the view is not designed to be editable by default. If you persist in editing a view, you need to create an editable view, for details, please check this blog:
    How to create an updateable view with ADO Entity Framework and with LINQ to SQL
    This blog is based on the SQL Server database, however, I notice that you are working with the Oracle database, I am not sure if the Oracle database provider for Entity Framework supports the editable view, I
     suggest you could confirm this on the Oracle database forum:
    https://community.oracle.com/welcome
    Regards.
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • Password validation with regular expression

    I'm trying to use a regular expression to validate a password. I've tried a number of different regex's that seem to work elsewhere but do not work in HTML DB. This includes a couple that I wrote and that I found on regex web sites. Specifically, I'm trying to validate that a string has:
    1. at least one special character
    2. at least one numeric character
    3. no more than 6 consecutive characters
    4. has a length between 8 and 14
    Does anyone know why some regular expressions do not work in HTML DB that work elsewhere or has anyone done a regex similar to this in HTML DB.
    Thanks!
    - Brian

    I see, I will use the [0-9] instead. The expression still does not work though. I simplified the expression down to try and figure out what doesn't work and it seems like it's the "?=".
    1. I first entered the expression:
    ([:alnum:]*[0-9])
    This expression just says there must be a number and it works fine in HTML DB.
    2. I extended it to:
    ([:alnum:]*[0-9])([:alnum:]*[a-z])
    This expression says that there must be a number followed by a letter. In this example "1a" works but "a1" does not.
    3. To make it not care about the order I would normally add "?=" like so:
    (?=[:alnum:]*[0-9])(?=[:alnum:]*[a-z])
    This should work for "a1" or "1a" because the ? says the order doesn't matter. When I try this in HTML DB neither "1a" or "a1" work.
    Any ideas?
    Thanks
    - Brian

  • Java validation with regular expression

    Hi
    I need to validate a string such that only numbers, alphabets, -, _, . is allowed and the below mentioned code works fine.
    if( ! l_name.matches("[A-Za-z0-9._-]+" ) ) {
    // do stuff when a valid name is found
    But i need to modify the above regex such that it should also allow space in the name. Any idea how to do that?
    Thanks in advance.

    I tried a space it does not work!!!Then you added the space between a character range or something.
    Here, this is a bit more compact:name.matches("[-.\\w\\s]+")

  • Java input validation with regular expression

    I am trying to make sure the user can only enter numbers 0 - 100, can any of you Java geniuses give me a hint. My regex matches the inputs I want, but when I enter a '9' I encounter an error when I cast the string to a double. Actually the input value is never assigned to the perc variable, but only when the input is a single digit. Here' s the piece of code that's giving me this headache:
    while(!in.hasNext("[0-9]")){
         try {
              perc = in.next("[0-9]{1,2}|100");
              break;
         } catch (InputMismatchException e) {
              System.out.println("Bad Input - Try Again");
              perc = in.next();
    dblPerc = Double.parseDouble(perc);And here's the error:
    Exception in thread "main" java.lang.NumberFormatException: empty String
            at sun.misc.FloatingDecimal.readJavaFormatString(FloatingDecimal.java:994)
            at java.lang.Double.parseDouble(Double.java:510)
            at applicant_database.View.showInput(View.java:46)
            at applicant_database.View.main(View.java:101)

    Add debugging code to your program to see what you're getting.

  • ADF Groovy Expression with bind variable and ResourceBundle

    Now I have ViewObject which have WHERE clause with bind variable.
    This bind variable is for language. Within bind variable I can change Value Type to Expression and into Value: I put +(ResourceBundle.getBundle("model.ModelBundle")).getString("language")+.
    Now if I run Oracle Business Component Browser (on AppModule) this works. In my ModelBundle.properties there is language=1 name-value pair. And with different locale I have different language number.
    Now if I put that ViewObject on one JSF, this bind variable expression does not work any more. Error:
    *oracle.jbo.JboException: JBO-29000: Unexpected exception caught: java.util.MissingResourceException, msg=Can't find bundle for base name model.ModelBundle, locale my_locale*
    Any ideas?
    10x
    Zmeda

    The most wierd thing is that, if I make ViewObjectImpl and insert this method
    public String getLanguage() {
    return (ResourceBundle.getBundle("model.ModelBundle")).getString("language");
    and call it in Bind Variable Expression Value: viewObject.getLanguage()
    IT WORKS!
    But why with groovy expression it does not work?
    Zmeda

  • Automatic entity validation

    Hi
    We are building an application framework on top of Toplink. One thing we added are field validators that are called on every setXXX(). The validator throws a ValidationException if there is a problem. This is automatic, and the developer doesn't need to care about it. ValidationException are atomaticaly sent back to the form by the framework and displayed using a message pool system...
    Now, we want to add an automatic entity validation system. The idea is to call the validate() method on the entity during the commit of the unit of work. The validate() method performs entity wide validations and throws a ValidationException if the entity is not valid. Of course, the framework must rollback the transaction if needed.
    How can wee do that in Toplink? I thought that events could help us, but I don't think we can throw exceptions from there...
    Any idea?
    Thanks
    Regards
    Eric

    Just to clarify,
    If you add this validation to your status attribute then it will validate that Reason is not null when you change the status to 4.
    If you want to raise an entity validation just add a new Entity Validator and the expression should be something like what you had:
    But slightly different
    Status != null ? (Status==4? (Reason!=null) : true) : true

  • Entity validation (Urgent)

    In my validateEntity call, how do I call a set method for an attribute that belongs to another entity?

    Just to clarify,
    If you add this validation to your status attribute then it will validate that Reason is not null when you change the status to 4.
    If you want to raise an entity validation just add a new Entity Validator and the expression should be something like what you had:
    But slightly different
    Status != null ? (Status==4? (Reason!=null) : true) : true

  • Groovy expression for error message in validation

    hi...
    using groovy expression i want to display a dynamic error message...(ie.i have a date field the date cant be a past date..if i enter the past date like (02-04-2012 )the error message should display with this date)

    For a validation rule on an entity attribute, you can use a Groovy expression to decide whether
    an error or a warning message should be displayed using the following expression:
    adf.error.raise("THIS_IS_AN_ERROR_MESSAGE")
    adf.error.warn("THIS_IS_A_WARNING_MESSAGE")
    In your case, you can customize the message and access the date attribute in the message as source.HireDate(Assuming HireDate is the date attribute)
    Hope it helps.

  • Regular Expression / String matching other than equality check with groovy.

    I want to have a string comparison operation using a groovy expression.
    Not an equality check, but something like
    #{variableName like 'IC%'?'true':'false'}
    I saw some operators like
    #{bindings.gradeName.inputValue =~ 'IC'?true:false}
    But it doesnt seem to be working.
    Is it possible with groovy?
    Arun

    Hi
    nything will do.
    And not using bean.
    This expression has to added in an AMX page (ADF Mobile
    It depends on where you want to execute this. Groovy in a validation script would be different to EL in a page as they would be in different stages in the lifecycle.
    Now for ADF MObile this may be different, I dont know.'
    If its to be part of a validation then you can call the source methods in groovy and do the comparison.
    from a validator for instance:
    source.getGradeName() returns the grade name before commiting.
    String enteredgrade = source.getGradeName();
    if (enteredgrade.index(0).equals('I') and enteredgrade(1).equals('C'){
    do what you want here. i.e. return true or false etc.
    el in a page would look entirly different but you can implement this same functionality in a bean, access it via the accessors and then return true or false.
    if you are already using EL and you managed to link your page with JSTL, you will have to define the access variable in the header section inorder to access it and then use "startswith", though I havent tried it this way.

  • (Groovy Expression) Get the no. of days between two dates

    Hi All,
    I am using ADF-BC-11g to create an entity object with 2 specific columns ActualDate and EstimatedDate both of Date type. I also want an additional field DaysBetweenTwoDates showing the difference between these two dates. Hence, I add another attribute DaysBetweenTwoDates in my entity object and after removing the Persistent property, I modify the expression field as ActualDate - EstimatedDate. When I test my AM, I get an error as below:
    *(oracle.jbo.JboException) JBO-29000: Unexpected exception caught: groovy.lang.MissingMethodException, msg=No signature of method: java.sql.Date.minus() is applicable for argument types: (java.sql.Date) values: {2009-04-01}*
    Can anyone please tell me how to achieve the same?
    Please note that I can not add a new column DaysBetweenTwoDates in the table nor can I have a new VO attribute subtracting and storing the difference as there are some logical and refreshing constraints.
    Any suggestions would be really helpful.
    Thanks
    Neeraj

    Thanks John,
    Oops...I did not think on this ground at all. Thanks for directing towards right direction. However, just to know, is that possible anyways thorugh groovy expression? Do we have any docs where we can search for the functions available in groovy expression?
    Regards,
    Neeraj

  • Groovy Expression Issue

    Hi,
    JDeveloper version: 11.1.1.3.
    I am setting the bind variable value using the below Groovy expression but the issue it is always setting the value "anonymous" instead of logged in user.
    viewObject.DBTransaction.session.userPrincipalName.toUpperCase()
    Note: Same is working fine in 11.1.1.2 version.
    Thanks.

    Hi,
    Thanks for the reply.
    Document says the following but I am not sure how to use incase of setting the bind variable for a VO.
    Application Module Returns Anonymous User After Logged In (9546149)
    Web applications using getUserPrincipalName() from ApplicationModuleImpl or SessionImpl may get 'anonymous' after user already logged in. Use ADFContext.getCurrent().getSecurityContext().getUserName() instead. Entities with histoty column kinds Created By and Modified By should override getHistoryContextForAttribute() in the entity impl class as follow:
    protected Object getHistoryContextForAttribute(AttributeDefImpl attr) {
    byte historyKind = attr.getHistoryKind();
    if ((historyKind == AttributeDefImpl.HISTORY_CREATE_USER) ||
    (historyKind == AttributeDefImpl.HISTORY_MODIFY_USER))
    Thanks.

  • Error While Deploying A CMP Entity Bean With A Composite Primary Key

    Hello all,
    I have a problem deploying CMP Entity beans with composite primary keys. I have a CMP Entity Bean, which contains a composite primary key composed of two local stubs. If you know more about this please respond to my post on the EJB forum (subject: CMP Bean Local Stub as a Field of a Primary Key Class).
    In the mean time, can you please tell me what following error message means and how to resolve it? From what I understand it might be a problem with Sun ONE AS 7, but I would like to make sure it's not me doing something wrong.
    [05/Jan/2005:12:49:03] WARNING ( 1896):      Validation error in bean CustomerSubscription: The type of non-static field customer of the key class
    test.subscription.CustomerSubscriptionCMP_1530383317_JDOState$Oid must be primitive or must implement java.io.Serializable.
         Update the type of the key class field.
         Warning: All primary key columns in primary table CustomerSubscription of the bean corresponding to the generated class test.subscription.CustomerSubscriptionCMP_1530383317_JDOState must be mapped to key fields.
         Map the following primary key columns to key fields: CustomerSubscription.CustomerEmail,CustomerSubscription.SubscriptionType. If you already have fields mapped to these columns, verify that they are key fields.Is it enough that a primary key class be serializable or all fields have to implement Serializable or be a primitive?
    Please let me know if you need more information to answer my question.
    Thanks.
    Nikola

    Hi Nikola,
    There are several problems with your CMP bean.
    1. Fields of a Primary Key Class must be a subset of CMP fields, so yes, they must be either a primitive or a Serializable type.
    2. Sun Application Server does not support Primary Key fields of an arbitrary Serializable type (i.e. those that will be stored
    as BLOB in the database), but only primitives, Java wrappers, String, and Date/Time types.
    Do you try to use stubs instead of relationships or for some other reason?
    If it's the former - look at the CMR fields.
    If it's the latter, I suggest to store these fields as regular CMP fields and use some other value as the PK. If you prefer that
    the CMP container generates the PK values, use the Unknown
    PrimaryKey feature.
    Regards,
    -marina

  • HT4259 I have been trying for hours to extend my Extreme Gen 5 network with an Express Gen 2.  But no matter what I do or try, it doesn't work.  What does happen is my internet gets block somehow when the Express looks like it's set up and 'green' - no in

    I have been trying for hours to extend my Extreme Gen 5 network with an Express Gen 2.  But no matter what I do or try, it doesn't work.  What does happen is my internet gets blocked somehow when the Express is online and looks like it's set up perfect and 'green' - but no internet connection for anything even though the Extreme is green and the modem is good.  Once I disconnect the Express, everything is good again.
    I've tried LAN, WAN, though a switch, direct connect, Extreme set to Extend the network, the Express set to be an extension.  Most of the time I get an error trying to update the Express.  But when it seems to be set up perfect, the entire house can't get to the internet.  Just when it looks right, it is so wrong.
    If anyone can give me exact steps (e.g., "...from the Base Station menu, select the Restore Default Setting option" vice "...just restore the defaults..."), I would greatly appreciate it.  I'm left to the conclusion that the Express is faulty.  I've been using Airport Utility 6.2 from Mountain Lion on one computer and Airport Utility 5.6.1 from Snow Leopard on another computer (the latter give more control while the former just want you to 'forget' the Express).

    I finally got it working.  I was trying to set it up ethernet.  My biggest mistake was when the new Express came on, I did not select 'Continue' - I went straight to manual thinking that I would get the most setup options in manual mode.  So everything I initially tried always resulted in 'wireless'.  Even when I would update or restore default settings, the Express would not completely restart. Or sometimes I would get an error. So most of the time I had to unplug it.  So when it came back up, none of my changes were retained. But there were a lot of times when everything was green and appeared to be fine. But anytime the ethernet cable was plugged in, no more internet.
    So here's the weird part.  When I finally tried 'continue' (vice manual), I would get 4 options.  One would be 'ethernet' extended.  So I would select it, it gave me green lights, all looked good, and still the same problem.  This is when I got frustrated.  I thought I had exhausted all possible combinations.
    But somehow when trying continue again after another restore, I only got 3 options.  One was the same ethernet extended option (can't remember what the missing 4th one was).  And this time it worked - it gave me the big green circle with the checkmark saying it was successful.  I don't know what I did different, but I know now that it won't work if 4 options come up to choose from.  It will work if only 3 options come up.  And success if only verified by the big checkmark.  Had anyone anywhere said the checkmark declaring success is validation, then maybe I wouldn't have gone down so many rabbit holes thinking it should have been successful.
    As for which Airport Utility I prefer, 6.2 looks nice, but it would just ignore the Express and would want me to 'forget' it and would not let me edit it.  Airport Utility 5.6.1 was the one that I ended up using the most and finally had success with.  It still strikes me as odd that there is no manually way to pick ethernet, it can only be choosen following a 'restore defaults', and only from the 3-option list (the 4-option list had the same ethernet choice, but it no worky).
    Thanks for the response.  I really do appreciate it.
    Aiport Extreme Gen5 - internet access and router
    Airport Express Gen2 - connected via ethernet, extending my wireless
    - configured while connect directly to the Extreme, but now on a switch (16-port hub)
    Using Airport 5.6.1
    1) Restore Defaults from Base Station menu
    2) Following restart, Select Continue
    3) Of the 3 option presented, select 'ethernet.... extend network...'
      - if 4 options are present, may not work
    4) Wait for the green circle with the big white checkmark.
    5) Connected Express to the switch where a cable went to other end of house - works.
    Dead-zone went from 2mbps to 24mbps.
    I probably spent 4 hours chasing my tail in anger.  The correct way took about 5 minutes total.
    Thanks again.

Maybe you are looking for

  • How do i send hyperlink to a text box within the same page

    how do i send hyperlink to a text box within the same page on iweb

  • Query Infoset not available in SQ01

    Hi all I have created an infoset in SQ02 and assigned it to a usergroup. If i look into the assigned Infosets in SQ03 or either from SQ02 itself, this infoset is being available in that assigned usergroup. But, when I go to SQ01 for creating a query

  • Xcelsisus connections mappings get lost once we export excel from xlf file

    Hi All, I am creating a dashboard in xcelsius 2008. I have around 50 live office objects and hence 50 live office connections in the xlf file. When I exoprt the excel from the xlf file and when i re- import the excel all the old live office connectio

  • How to speed Portal's refresh rate?

    Dear All, When I develop the portal application with some page modified, it seems that portal server has cached the old pages somewhere so that I can not see the new one immediately. Even I delete the __xx.java and __xx.class in WEB-INF directory of

  • ICloud on 4s iOS 6 will NOT delete...

    Trying to delete mt iCloud acct from 4s, just spins and spins, and then after what seems like an hour, does nothing. Do I have to reset and delete the phone setting to get this to go away? Did a basic reset, nothing. Very frustrated.