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.
Similar Messages
-
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,
JoelHi,
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 -
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
ZmedaThe 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 -
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 PrasadCan 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
NeerajThanks 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 RCHi,
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,
SandeepWhat 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.
Regardsdetails 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 -
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:28for 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?
ThanksJust 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. -
Hello All,
I'm having an issue with adding parameters to the report with the below statement. When I add @Start as a parameter in report and set the default value to =DATEADD( "M", -1, DATEADD("QQ", DATEDIFF("QQ", 0, Today()),0)),
I get an error saying - An error occured during local report processing. How can I set default value for @End to - DATEADD(day, -1, DATEADD(month, DateDiff(month, 0, @Start) +1, 0))? Thanks
declare @Start as date
declare @End as date
declare @NextStart as date
Declare @NextEnd as date
Set @Start= DATEADD( MM, -1, DATEADD(QQ, DATEDIFF(QQ, 0, GETDATE()),0))
Set @End = DATEADD(day, -1, DATEADD(month, DateDiff(month, 0, @Start) +1, 0))
Set @NextStart = DATEADD(MONTH, 1, @Start)
Set @NextEnd = DATEADD(day, -1, DATEADD(month, DateDiff(month, 0, @Start) +2, 0))
Thanks,
AmolHi Neha,
Thank you very much for your help. The expressions you suggested works perfect. The only issue is with @NextEnd paramater. I get default date as 09/30/2014 instead of 07/31/2014.
For @NextEnd
=DateAdd("d",-1,DateAdd("q",1,DateSerial(Year(Now()), (3*DatePart("q",Now()))-2, 1)))
Thanks again for your help.
Amol -
I am working in a visual studio premium 2013 solution that has a web project and class library. The web project is called UI and the class library project is called AppService. We are using ServiceStack and AngularJS. The UI project
is calling the AppService project via AngularJS controller. The class library is a pass through which calls APIs for data.
The web project was created as an empty web project that another team member created. Items were added as needed. It is set up to use IIS Express. The web project is defined to use port 30000 so that the URL is http://localhost:30000/.
When I try running the application using port 30000 I am not getting data back; heck, when I am in debug mode I am not stepping into the AppService project. I am the only person on the team experiencing this problem. There are four other developers
on the team.
In the UI project we have a Global.asax file. In the Application_Start property we are setting a new instance of the AppServiceAppHost object. We are able to step into this method when debugging.
The crux of the problem is that when I change the port number to something other than 30000 (e.g. 30001, 30002) everything works. We are getting data; we step into the AppService project when debugging.
When I am using port 30000, I am seeing in the IIS express logs the error "Object reference not set to an instance of an object" with the stack trace pointing to ServiceStack.HttpHandlerFactory..ctor().Hi Gerald,
Thank you for posting in the MSDN forum.
Actually this forum is to discuss the VS IDE usage, if this issue is related to web project, you could ask this question in the ASP.NET forum:
http://forums.asp.net. If then, you could get an answer more quickly and professional. Thanks for your cooperation
Best Regards,
Jack
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.
Maybe you are looking for
-
Basic Strategy / Best Practices for System Monitoring with Solution Manager
I am very new to SAP and the Basis group at my company. I will be working on a project to identify the best practices of System and Service level monitoring using Solution Manager. I have read a good amount about SAP Solution Manager and the concept
-
Vista system crashed due to a corrupted system file. The C drive was reformatted, and windows reloaded, along with the rest of my programs. Before the drive was reformatted, an image was made of it on a USB drive to save all the data. Now I need to k
-
I have an apache server connected to tomcat via ajp13. In the tomcats catalina.out file it keeps creating new ajp13 background threads up to its configured limit, and never releases them. When it reaches its limit, you get this error:- Ajp13Connector
-
What is the replacement cost of a 250Go hard disk (McBook Pro Intel Core Duo 2009)
My computer does'nt run anymore. The cause seems to be a failure in the hard ware. Can anybody give me an idea of the cost for the replacement of the internal device (it used to be a 250 Go Hitachi hard disk). Thanks a lot
-
PS shows encumbrance (2A) but reservation was closed using FMMC
What could be the cause of a handfull of remaining balances on Funds Reservations (containing WBS elements)that have been closed using FMMC to still show in Project Systems report S_ALR_87013532 (Plan/Actual/Variance). For example, we have one scenar