Groovy expression

hi....
how to set a dynamic error message in entity object validation using groovy expression

Since you donot tell us your Jdev version nor your exact use case .. I would assume blindly your use case and say that this would help :)
https://blogs.oracle.com/grantronald/entry/dynamic_error_messages_from_a

Similar Messages

  • 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

  • Using groovy expressions to get a value of the current row

    Hi,
    I have a bounded task flow. The first step in the flow is calling an ExecuteWithParameters on one of my views. Based on the result of this query, I want to go to either Page1 or Page2.
    So I have a router. I first tried to route based on whether or not the result of the query contained only one row. That worked fine. But I want to add a condition to that.
    Basically, if the query returns one row AND that row has an attribute named 'Noc' == 1, then I want to go to Page2. Otherwise, go to Page 1.
    Right now to get the estimatedRowCount I am getting the iterator from the pageDef file created for my ExecuteWithParams object. To see if 'Noc' == 1, I tried this:
    #{data.rcl_view_reimbCode_search_results_task_flow_reimbCode_search_results_task_flow_ExecuteWithParamsPageDef.ReimbCodeSearchView1Iterator.currentRow.getAttribute("Noc") == 1}
    But it is complaining of grammar issues.
    What is the best way to go about getting the value of my attribute in a groovy expression?
    Thanks,
    Joel

    Hi,
    the best way is to use a managed bean reference
    1. create a binding for the router
    2. Expose the queried iterator in the PageDef file
    3. write a managed bean that accesses the binding
    BindingContext bctx = BindingContext.getCurrent();
    BindingContainer bindings = bctx.getCurrentEntry();
    DCIteratorBinding iter = bindings.get("NameOfIterator");
    // i) get estimated row count
    // ii) get attribute value
    //iii) evaluate
    // iv) return true/false
    Reference the managed bean from the router
    Frank

  • Groovy expression evaluation

    Hi,
    The following groovy expression is returning null when validating attribute. If I use (PolicyNum > 2000000) in the if condition it is working fine. If use (newValue < MaxManualClassEndDate) in the if condition that is also working as expected. if I combine these two conditions using && it is failing. Can you please suggest right way to merge two expressions using groovy.
    if ( (PolicyNum > 2000000) && (newValue < MaxManualClassEndDate)) {
    print "Policy Term EffDate $newValue is less than $MaxManualClassEndDate";
    return false;
    Thanks and Regards,
    S R Prasad

    Can any one help in resolving the groovy expression.
    It is not working when there is && in the if condition between two expressions.

  • (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

  • Accessing AppModuleImpl methods from Groovy expressions?

    From a VO View Criteria bind variable I'm attempting to call an accessor (aka. getValue) in it's parent AppModuleImpl, via a Groovy expression. I thought I could do something like:
    ((model.AppModuleImpl)object.getApplicationModule()).getValue()
    ...but at runtime I'm getting an error that Groovy doesn't know model.AppModuleImpl.
    I must be missing something here. Does anybody have the Groovy syntax for calling methods in the parent AppModuleImpl please? I've searched Grant Ronald's ADF Groovy whitepaper with no success, and I haven't found an example on these forums either.
    With thanks,
    CM.
    PS. JDev 11.1.1.2.0, ADF BC + ADF Faces RC

    Hi,
    I am not sure but may be you found this post useful http://andrejusb.blogspot.com/2010/01/storingaccessing-objects-in-adf-bc.html
    one more thing i did lately you can try if it works
    I created Method in AppModuleImpl class and called it in VOImpl class with AM object and then assigned it as expression to the attribute value in VO it should work for Bind variable value as well
    //Method in AM
      public String sayHello(){
        return "Hello World";
    //Method in VOImpl
      public String getHelloFromAM(){
        AppModuleImpl am = new AppModuleImpl();
        return am.sayHello();
    //Attribute "HelloTEXT" default value
    adf.object.getHelloFromAM()Hope it the same thing you are looking for
    Baig
    Edited by: BaiG on Jul 12, 2010 1:02 PM

  • Re:Groovy Expression for time

    Hi All,
    Iam using Jdeveloper 11.1.2.3.0 ,my requirement is that :Groovy expression for time
    Can any one send me the above requirement
    Thanks,
    Sandeep

    What time?
    Yesterday noon?
    Now?
    You need to give us a use case.
    Check out GroovyCookbook: Dates and Times
    Timo

  • Groovy Expression at instance level.

    Hi,
    Iam using JDev 11.1.1.5.0.
    I've an ViewObject and then applied ViewCriteria. Now I want to apply groovy expression sum(column1). Is it possible? Please suggest, if you have any clue.
    Thanks,
    Samba.

    Hi,
    Going through this would give you the basics of groovy expressions : http://www.oracle.com/technetwork/developer-tools/jdev/introduction-to-groovy-128837.pdf
    -Arun

  • Groovy expression for fetching current user details

    I have created a view object that retrieves user details from the database. Also for dynamically getting the details of the current user logged in i have defined a bind variable currentUser and the default expression is adf.context.securityContext.userName.When i give the fixed literal value as user name the details are fetched. However details are not fetched when i use the groovy expression. Can i get some help on this please.
    Regards

    details are not fetched when i use the groovy expressionby using groovy you cant the details
    i cant get you, is this you question?
    some hints, here
    groovy expression as default value in a Entity's Field Problem

  • 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.

  • ADF Groovy Expression for calculation

    Hi,
    I am using JDeveloper 11gR2. For a transcient attribute in a VO, I must add an expression that will calculate and return a value according to a business rule.
    I.e. if 'Standard' then column a * 0.3 or column b * 0.3
               elsif 'Premium' then column c * 0.3
               else 'Luxury' then column d * 0.3 Of course, using the appropriate Groovy expression. Does anyone have an example I could try?
    Thanks!
    Edited by: user545194 on 02.02.2013 07:28

    for example if att is the attribute that you want to calculate and it depend on val attribute
    the groovy exp is done on att
    if(val=='Standard') return a * 0.3
    else if(val=='Premium') return c * 0.3
    else if(val=='Luxury') return d * 0.3
    you must add attribute val, a, c ,d to the dependent attribute
    hope it helps
    Fakhri

  • 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

  • Error in groovy expression: Illegal type in constant pool

    Hi,
    I intermittently get this error on my page:
    EMGC_OMS1 ERROR] [ http://oracle.adfinternal.view.faces.config.rich.RegistrationConfigurator [tid:
    userId: SYSMAN ecid: 004emUHK7jA9XbWLHyl3if0002JD0011gG,0:1 APP: emgc URI: ... ... ... :Server Exception during PPR, #15[[ javax.servlet.ServletException: java.lang.VerifyError: (class: org/codehaus/groovy/runtime/ArrayUtil, method: createArray signature: ()[Ljava/lang/Object;) Illegal type in constant pool
    at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:341)
    at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:26)
    Caused by: java.lang.VerifyError: (class:
    org/codehaus/groovy/runtime/ArrayUtil, method: createArray signature:
    ()[Ljava/lang/Object;) Illegal type in constant pool
             at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:125)
             at bc4j.oracle_sysman_core_event_console_uimodel_view_IssueListVO_PriorityLocalizedLabel_null.gs.run(bc4j.oracle_sysman_core_event_console_uimodel_view_IssueListVO_PriorityLocalizedLabel_null.gs.groovy:1)
             at oracle.jbo.ExprEval.internalEvaluateGroovyScript(ExprEval.java:1208)
    The IssueListVO getPriorityLocalizedLabel uses a groovy expression:
    oracle.sysman.core.event.common.uimodel.util.MetadataUtil.getPriorityLabel(Priority.intValue()).
    The Priority field is defined to be numeric, and the repository data shows all records having a value of 0, so this groovy expression should behave correctly.
    We are using Build JDEVADF_11.1.1.5.0_GENERIC_110409.0025.6013.
    Any ideas on how to resolve this?
    Thanks!                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

    cn u chk this
    LinkageError

  • 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.

  • ADF : Groovy Expression

    Hi
    Is it possible to reference the current entity object name using groovy? I would like to get the entity name in a validator to customize the error message.
    I currently have a validator and an error message with two placeholders,
    Attribute {0} is not allowed to be referenced on {1},
    Placeholder {0} is being resolved using, source.hints.AttributeName.label, I cannot find a suitable expression to resolve placeholder {1}.
    Thanks.

    Hi,
    Can you try
    adf.object.getDefinitionObject().getAliasName()-Arun
    Untested

  • Error in groovy expression

    Hi.,
    I am using jdev 11.1.1.5
    In the GlHdEO fro attribute year i had used grrovy expression as
    ValueType:  Expression
    Value: object.Rowset.getCurrent('FyYear')While i click the create insert button i am getting following error
    <font color="red"> Name Rowset not found in the given object :Entity [null] </font>
    My scenario:
    I am trying to get the value of FyYear to GlHd.Year
    so that it will be default value for that attribute

    Hi,
    If same Entity try
    FyYear
    if use viewlink
    check
    http://www.gebs.ro/blog/oracle/adf-bc-viewlink-viewlinkaccessor-and-groovy/

Maybe you are looking for

  • Transferring apps from one itunes account to another

    I bought the original IPad from a family member, so it was set up with there ITunes account and all of the apps that are on it. I would like to transfer everything that is currently on the IPad over to my computer with my ITunes account, without havi

  • Flash player shows lines on anything that moves V.WIN 10,1,102,64

    So   if I try to watch any video or a moving add pops up and a little blob moves it makes the video that makes it move  and makes it dissapear from my screen but i can see the still part of the add. Comp spesifications Windows 7 64BIT!!!! Dell Inspir

  • Cannot copy and paste while online

    Can you help? I cannot copy and paste parts out of webpage or document that I see online. I can during iPages. MacBook Pro

  • After updating and restoring some purchased music is "unauthorized"

    I downloaded an update for my Ipod and then was forced to restore my Ipod when it was not recognized by Itunes. After the restoration process I find a few purchased albums come up as not being authorized to play. I go through the process of reauthori

  • Labview Driver for TPS 2014

    I am using Labview to control Oscilloscope TDS 2014. I downloaded the plug in and play driver from  http://sine.ni.com/apps/utf8/niid_web_display.model_page?p_model_id=540. I want to test the connection between the driver and the instrument. For this