execution of groovy expression based on a condition
Hello
I'm on jdev 11.1.2.4 and MySql db.
I use under groovy expression to get the domain in my name of the VO. area is a temporary variable.
key oracle.jbo.Key = new oracle.jbo.Key (AreaId);
Return LookupAreaVO1.findByKey(key,1) [0] .getAttribute ("AreaName");
It works very well if there is a value in AreaId. However, he throws a NPE when there is no value.
How I can only run this code if AreaId has value?
It works very well if there is a value in AreaId. However, he throws a NPE when there is no value.
How I can only run this code if AreaId has value?
Add an if to test the value AreaId.
If (AreaId! = null) {}
key oracle.jbo.Key = new oracle.jbo.Key (AreaId);
Return LookupAreaVO1.findByKey(key,1) [0] .getAttribute ("AreaName");
}
Tags: Java
Similar Questions
-
Merge the queries based on the conditional
Apex 4.2
I have a pretty complex question. I have a page that will have a selection list on the data entry form. The selection list contains a list of both 1) Active only or 2) active and inactive areas. We show the active areas when we create a new record (P101_ID IS NULL), we appear active and inactive sectors when you edit a record (P101_ID IS NOT NULL). I have therefore two separate queries to account for each case. Simple so far.
Problem I am seeing that create two lists of selection on the page and put a separate condition on each one (hiding one of selection lists depending on the case the ID IS NULL or the ID IS NOT NULL) does not work. So I was wondering if there was a way to combine queries for that to work based on a conditional statement. I did experiment with the instructions box and unions, etc., but my questions are a bit complicated. They are as follows:
LIST OF ASSETS SECTORS (P101_ID is NULL)
Select unique ISEC.inspection_sector_name, ISEC.inspection_sector_id From INSPECTION_SECTORS ISEC left join HWE_INSPECTION_SCHEDULING SCH on ISEC.inspection_sector_id = SCH.inspection_sector_id Where (ISEC.hurricane_protection_flag = :P157_IS_HURR and ISEC.river_protection_flag = :P157_IS_RIV) AND ISEC.superseded_date is null AND ISEC.commenced_date is not null AND ISEC.inspection_sector_id not in ( Select ISEC.inspection_sectors_id From INSPECTION_SECTORS ISEC left join HWE_INSPECTION_SCHEDULING SCH on ISEC.inspection_sector_id = SCH.inspection_sector_id Where SCH.high_water_event_id = :P157_high_water_event_id AND SCH.inspection_date = :P157_inspection_date) OR ISEC.inspection_sector_id = :P157_inspection_sector_id AND ISEC.superseded_date is null Order by inspection_sector_name
LIST ACTIVE AND INACTIVE SECTORS (P101_IS is NOT NULL)
Select inspection_sector_name, inspection_sector_id From ( Select ISEC.inspection_sector_name, ISEC.inspection_sector_id, '0' as this From dual, INSPECTION_SECTORS ISEC left join HWE_INSPECTION_SCHEDULING SCH on ISEC.inspection_sector_id = SCH.inspection_sector_id Where (ISEC.hurricane_protection_flag = :p157_IS_HURR and ISEC.river_protection_flag = :P157_IS_RIV) AND ISEC.superseded_date is null AND ISEC.commenced_date is not null AND ISEC.inspection_sector_id not in ( Select ISEC.inspection_sector_id From inspection_sectors ISEC left join HWE_INSPECTION_SCHEDULING SCH on ISEC.inspection_sector_id = SCH.inspection_sector_id Where SCH.high_water_event_id = :P157_high_water_event_id AND SCH.inspection_date = :P157_inspection_date) OR ISEC.inspection_sector_id = :P157_inspection_sector_id AND ISEC.superseded_date is null UNION Select unique ISEC.inspection_sector_name|| ' [CLOSED]', ISEC.inspection_sector_id, '1' as this From dual, INSPECTION_SECTORS ISEC left join HWE_INSPECTION_SCHEDULING SCH on ISEC.inspection_sector_id = SCH.inspection_sector_id Where ISEC.superseded_date is not null and ISEC.commenced_date is not null AND ISEC.river_protection_flag =:P157_IS_RIV and ISEC.hurricane_protection_flag = :P157_IS_HURR AND ISEC.inspection_sector_id not in ( Select ISEC.inspection_sector_id From INSPECTION SECTORS ISEC left join HWE_INSPECTION_SCHEDULING SCH on ISEC.inspection_sector_id = SCH.inspection_sector_id Where SCH.high_water_event_id = :P157_high_water_event_id AND SCH.inspection_date = :P157_inspection_date) OR ISEC.inspection_sector_id = :P157_inspection_sector_id NAD ISEC.superseded_date is not null Order by this, inspection_sector_name asc
If the requests are quite complex. I tested the times and they work in APex, separately from the course. Forgive me if I have mispeled anything. But any help on this would be greatly appreciated. Thanks in advance.
Thank you for taking to your friend Frank. You are a bird-guy (my attempt at sarcasm). Nobody has questioned whether its knowledge base; more so in the way he responded to my original post did not «do» Like the people who come on this forum looking for help to those who have greater knowledge, it would be nice to be greeted a little more friendly, lol. Just my thoughts. But, feel free to correct my spelling test, grammar and syntax in my sentences so (the effort once again to emphasize that I misspelled 'AND', and that the request would not be performed--> of course... smh... you are funny)
Apparently I failed to explain the issue in its entirety. I should start by saying... "I have two separate petitions that I tested and already working and am looking to put on a list of selection (at the top) with a conditional execution statement one or the other, through the conditional statement, but again, I was looking for more so for syntax and structure." I'm sorry, I forgot to mention that.
Anyway, enough of this. I found a solution to my problem:
Within the Apex 4.2, you can have a list of selection as a page element. I want to display different results depending on whether Yes or no P101_ID is set to Null or NOT NULL
P101_ID is a primary key for a table.
P101_ID is not the exact name I use in my application / request however.
In addition, you don't need to include double; It's not make or break the query. Something that I forgot to omit them.
In addition, something along the lines of
Select inspection_sector_name, inspection_sector_id From ( .....all the stuff in query 1.......) Where P101_ID is null UNION Select inspection_sector_name, inspection_sector_id From ( ....all the stuff in query 2.....) Where P101_ID is not null
will work on a selection list in the APex. So problem solved. Thank you for all your wonderful insight, of words and thoughts. Thank you.
-
problem in the groovy expression
Hi all
I have three attributes: "WorkDateFrom", which is of type Date and "Working days" which type number and "WorkDateTo", of type Date.
the value of 'WorkDateTo' must be
After the execution of the Application Module to test. I write the value of "WorkDateFrom" and the value of "Working days", the WorkDateTo value will be zero.WorkDateFrom+WorkDays
This expression is wrong?Just tested on the opinion of the employees in the HR schema. My groovy expression
HireDate+DetartmentId.intValue()
Displays the correct result. So, if your WorkDateFrom is of type Date and days of work is of type number and then
WorkDateFrom + WorkDays.intValue()
should work. Always check null values.
Timo
-
Hide an entire column based on a condition
Hello
I'm trying to completely hide a column in a table based on a condition, if the column was not present. I wrote two conditional regions for the header and data, but it is still showing up. Any help would be appreciated. The XML model RTF, the PDF generated and the output I'm looking is attached. Thank you.
Please check your email that I have forwarded to update the model.
I counted occurrences of January in your xml and formed the condition based on the fi
MONTH
-
Groovy expression to return a string.
Version 12.1.3
I got this groovy expression that evaluates to true or false
don't #{pageFlowScope.userName, null}How to rewrite, so that it returns a string when it is false?
Thank you
I think it's just EL, not Groovy.
#{pageFlowScope.username == null? {"it was null": 'it was not null'}
-
Error with groovy expression of sequence number of EO attribute assignment?
Hello worldMy version of Jdeveloper is 11.1.2.3.0.
Starting from this post: https://tompeez.wordpress.com/category/adf/page/6/
I found to add a groovy expression for the sequence number to my attribute. I created a single sequence and added that the groovy expression to my attribute but got the error below:Utils > < buildFacesMessage > ADF: addition of the following JSF error message: failed to start, bc4j_model_TestEntityObject_Empno_null_gs.groovy: 1: lack of hook closing ' > ' for generic types.
solution: Please specify the missing support! @ line 1, column 12.
1 errororg.codehaus.groovy.control.MultipleCompilationErrorsException: failed to start, bc4j_model_TestEntityObject_Empno_null_gs.groovy: 1: lack of hook closing ' > ' for generic types.
solution: Please specify the missing support! @ line 1, column 12.
1 errorNote: groovy expresion used in my EO attribute is given below:
(new class < SPAN > 'skimlinks-fidget' = > oracle.jbo.server.SequenceImpl ("SampleSeq", adf.object.getDBTransaction ())) .getSequenceNumber </span >)also used:
(new class < SPAN > 'skimlinks-fidget' = > oracle.jbo.server.SequenceImpl ("SampleSeq", adf.object.getDBTransaction ()) .getSequenceNumber () </span >What can be the problem?
Please give me your valuable contributions...
Thank you.Sorry, somehow the code in the blog is messed up. Use
(new oracle.jbo.server.SequenceImpl ("SampleSeq", adf.object.getDBTransaction ()) .getSequenceNumber)
Where SampleSeq is the name of the sequence defined in the comic book.
Timo
-
Groovy expression in the output text
Hi all
I want to use groovy expression in the output as text
< af:outputFormatted value = "#{adf.currentDate}" id = "2" / > "
< af:outputFormatted value = "#{adf.userSession.userData.user}" id = "2" / > "
but the values are not seen at the exit and the value to the property inspector area becomes red...
This is because groovy can be used on the side of the model. For the user interface, you use the expression language.
For the user, you can use adfsecurity information (control http://docs.oracle.com/cd/E14571_01/web.1111/b31974/adding_security.htm#CHDFFGDJ)
To date, you must implement a bean method that you call via EL.
Timo
-
Insert data into the same table based on certain conditions
Hello. I'm new to this forum.
I have to write a stored procedure to insert data in a table MYTABLE say, having a structure like:
Col1 Col2 Col3... TotalInstallments CurrentInstallment PaidAmount MonthYear
I have to insert all the data that it is in the same table (MYTABLE) except change some fields based on certain conditions:
1. if PaidAmount > 0 & & CurrentInstallment < TotalInstallment then
CurrentInstallment = CurrentInstallment + 1
2. in the field MonthYear I have data ex. 01/2012, 11/2012 formate(month/year)...
So, I have to insert data by incrementing the month and year. for example:
If currentdata is 11/2012 next data will be 12/2012
But following will be 01, 2013
I have to select all records that belongs to the previous month (across the field MonthYear) and put the audit on each record selected and insert data and then turns them into table (MYTABLE) even.
How to achieve that?
Thank you.978184 wrote:
Hello. I'm new to this forum.
I have to write a stored procedure to insert data in a table MYTABLE say, having a structure like:Col1 Col2 Col3... TotalInstallments CurrentInstallment PaidAmount MonthYear
I have to insert all the data that it is in the same table (MYTABLE) except change some fields based on certain conditions:1. if PaidAmount > 0 & CurrentInstallment
CurrentInstallment = CurrentInstallment + 1
2. in the field MonthYear I have data ex. 01/2012, 11/2012 formate(month/year)...
So, I have to insert data by incrementing the month and year. for example:
If currentdata is 11/2012 next data will be 12/2012
But following will be 01, 2013
I have to select all records that belongs to the previous month (across the field MonthYear) and put the audit & on each of the selected data record and insert then turns them into table (MYTABLE).You can do this way:
This is not tested, but if you can provide the example of table structure and data (IN create table and insert scripts), it can be put to the test.
insert into your_table (col1, col2, col3...current_installment, month_field) select col1, col2, col3.., current_installment + case when paidamount > 0 and current_installment < total_installment then row_number() over ( partition by column1, column2,.. columnn -->You may choose partition if you want the --Increment of Current_installment to reset after particular combination ends order by primary_key -->Order the Increment, you may choose to add more columns to order by ) else 0 --> if condition is not met, then Add 0 end curr_installment, add_months(to_date(month_field, 'MM/YYYY'), 1) nxt_month from your_table;
-
Generate reports based on two conditions
Dear all,
I generate reports based on satisfactory conditions in two columns in a table.
For example.
I have a table test1 with columns A, B, C, D, E
Now, I want to create reports based on the research of two columns A and b. What is the preferred method to do?
Thanks in advance.What is the preferred method to do?
Write the appropriate query:
select a,b,c,d,e from test1 where a =
and b = In reports, the State may be a user input parameter:
select a,b,c,d,e from test1 where a = :parameter1 and b = :parameter2
-
How to call a method defined in AppmoduleImpl using a groovy expression?
Hi experts,
With the help of jdev 11.1.1.5.0 - adfbc battery.
I followed this post as the blogger says.
How to call a method defined in AppmoduleImpl using a groovy expression?
https://blogs.Oracle.com/ADF/entry/how_to_call_a_method
While a button insert hit
Suite error survey.
It is my code for the function.java.sql.SQLException: ORA-20483: ADM- ORA-06512: at "RMSTD.FUNC_FIND_PLNT_DESC", line 22 ORA-06512: at line 1 at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:457) at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:405) at oracle.jdbc.driver.T4C8Oall.processError(T4C8Oall.java:889) at oracle.jdbc.driver.T4CTTIfun.receive(T4CTTIfun.java:476) at oracle.jdbc.driver.T4CTTIfun.doRPC(T4CTTIfun.java:204) at oracle.jdbc.driver.T4C8Oall.doOALL(T4C8Oall.java:540)
Reason behind:CREATE OR REPLACE FUNCTION func_find_plnt_desc ( p_bu VARCHAR2, p_plnt_id VARCHAR2, p_lang NUMBER ) RETURN VARCHAR2 IS CURSOR cur_find_plant IS SELECT bup_name1, bup_name2 FROM bus_unit_plants WHERE bup_bu = p_bu AND bup_plant_id = p_plnt_id; rec_find_plant cur_find_plant%ROWTYPE; BEGIN OPEN cur_find_plant; FETCH cur_find_plant INTO rec_find_plant; --RAISE_APPLICATION_ERROR(-20999,P_BU||P_PLNT_ID); IF cur_find_plant%NOTFOUND THEN raise_application_error (-20483, 'ADM' || P_PLNT_ID ||'-'||P_BU); --NULL; END IF; CLOSE cur_find_plant; IF p_lang = 1 THEN RETURN (rec_find_plant.bup_name1); ELSIF p_lang = 2 THEN RETURN (rec_find_plant.bup_name2); END IF; END; /
while hitting the insert means null from the value of the survey so error function.
If am not hitting doesn't mean no problem. the function works correctly return description.
can someone help me how to override?
Published by: ADF7 on April 10, 2012 23:51ADF7,
the subject of the post has nothing to do with the question (for as far as I see it).
As you can see the error message clearly comes from the procedure pl/sql you call the application module, works of groovy appeal method.We cannot decide what makes your service if you pass null as a parameter. You can check the settings before you proceed to the procedure or write the procedure in how it treats null parameters.
Timo
-
How to enable or disable a paragraph based on a condition in the BIPS
Hello reading,
<? country? >
How to display a line based on a condition in the DARK...
I have a tag as a country that has the value zero or in India, I shouldn't show paragraph
para should be included
and also, I don't want the line below to access his location
How can I do this...
pls helpI sent you the code to achieve this. Take a peek inside.
Thank you
BIPuser -
Remove duplicates based on a condition
Hi all
I need help on a query to remove the duplicates based on a condition.
For example, my table is
FE CC DATE FLAG
----------------------------------------
FE1 CC1 10/10 FB
FE1 CC1 FB 9/10
FE1 CC1 11/10 AB
FE1 CC2 9/10 AB
FE1 CC2 10/10 FB
FE1 CC2 11/10 AB
I want to delete all duplicate rows FE and CC, based on the sub condition:
DATE < MAX (DATE) WHERE FLAG = "FB".
This means I want to remove the FB 9/10 FE1 CC1 line
but not lines
FE1 CC1 10/10 FB
and
FE1 CC1 11/10 AB
as only the FE1 CC1 line 9/10 FB has date < MAX (DATE) WHERE FLAG = "FB".
Similarly, I want to keep
FE1 CC2 10/10 FB
FE1 CC2 11/10 AB
but not
FE1 CC2 9/10 AB
Thank you very much.Can be like that...
delete from
t where dt < ( select max(dt) from where fe=t.fe and cc=t.cc and flag='FB' ) -
Disable a button based on a condition
Hello
I want to disable a button based on some condition.
Suppose I want to disable a particular button, if the value of ACTIVE_FLAG in a table "Y".
I put disabled = true in the attributes of the button, but I don't know where to put the condition.
Thank you
DeepakDeepak,
Put this in the footer text.
Make sure you have set the source of the item as "always replace.." for P1_ACTIVE_FLAG point and get the value from database.
See this link for the Javascript API of APEX
See you soon,.
HariPublished by: Hari_639 on October 30, 2009 12:45
-
display edit link based on a condition problem
Hello
Someone can such me how I can display the link change in every line of my report based on a condition... is the query on which my report is formed, as shown below
SELECT COMPUTER_ID,
COMPUTERNAME, BATCH, DESCRIPTION, OPERATING_SYS.
PRIMADMIN_PHONE, PRIM_ADMIN, PRIMADMIN_CNID,
SECONDADMIN_PHONE, SECONDARY_ADMIN, SECADMIN_CNID,
RACK_NUM, MAINTENANCE_WINDOW from cts_masterserverview where ACTIVE_STATE = 'Active'.
All these data are from several fields. If city and Andy see, probably they will remember... They helped me to change this option much... my problem is now
I did the columns computer_id, which is the key in all other tables as a button change. And when the user clicks this edit button, data row respective are filled in the form, where the data can be changed...
My requirement is now, at each change of line button should appear only if the user logged on as long as the PrimAdmin of this line... I am recovery PrimAdmin_CNID so that it can be compared against: APP_USER. All others should be able to view the data, but not modify... I am not able to figure out how I can conditionally display as I do for the other buttons.
Can someone give an idea on how to do...
Thank you
Yvette
Published by: user0012 on May 1st, 2009 13:25Hi David,
Use the following query to conditional change the link,.
SELECT CASE WHEN PRIMADMIN_CNID = :APP_USER THEN '' ELSE ' ' END Edit ,COMPUTER_ID ,COMPUTER_NAME ,STATUS_ID ,DESCRIPTION ,OPERATING_SYS ,PRIMADMIN_PHONE , PRIM_ADMIN ,PRIMADMIN_CNID ,SECONDADMIN_PHONE ,SECONDARY_ADMIN ,SECADMIN_CNID ,RACK_NUM ,MAINTENANCE_WINDOW from cts_masterserverview where ACTIVE_STATE = 'Active' Add onclick= before "javascript above and Change the number 7 in the javascript to the page where you have edit form.
Thank you
Manish -
Make some lines in a table based on a condition.
I have a table based on a View object that displays four columns: Secure, Description, username and Date.
Currently it displays all the data based on the request of the VO. When a user clicks on a line, the complete 'Description' is showed in a below - rich text editor where it can be updated and saved in the database.
I am facing a problem of application of security for the page. The scenario is as follows:
If a logged-in user (defined in the flowrate range of Page), does NOT match the user name on a specific line (user name of the database), AND "Safe" is TRUE (in the case of the database, '1'), then the 'Description' should NOT be visible.
Looks like I can set the property 'Lent' on the specific Description column, but if it is not made and the user clicks on the line, the value of the Description always displayed in the below rich text editor.
What would be the best way to do this? Is it possible to manually set the Description of the '< Secured >"(or something) in the table and the text of the editor if the condition is true? I hope that this is possible is because I want that line to be always present, just the Description hidden in both components.
This should be done by programming or can be done with an EL expression?
If by programming is the only way, how can I write logic for Page loading?
Thank you!
This can be done with an EL expression. You can write an EL expression for visible or properties readonly or disabled of the elements present within af: column.
The EL expression can look like the line is #{pageFlowScope.userName. The name}, click the line if you have written the code to display Description in your bean to manage programmatically you can access pageFlowScope username and apply the same condition.
Maybe you are looking for
-
New samsung 23 "monitor how to fill the horizontal screen
bought the new samsung 23 "monitor. How can I fill screen horozonially? A moderator has moved this thread to Windows for the hardware and drivers Forum of Feedback Forum
-
HP 252 dw: printing of business cards
Just bought HP 252 dw; Can he handle the card stock business Avery 8.5 x 11 sheets they are 247 g/m2. Don't want to damage the printer.
-
Update for Windows XP (KB2567680) security has failed - error Code: 0 x 80070003
Security update for Windows XP (KB2567680) failed - error Code: 0 x 80070003 I tried to install update 3 - 4 times but it continues to not be updated, can someone please tell me what to do.
-
When left and up/down keys are pressed together, one that is pressed subsequently does not work
-
HP Officejet Pro more than 8600
When I scan from my HP (just installed) in Word, the words "scan Addin Trial" appear on my analysis in black letters "BOLD" that I can't remove. Can someone help me with this aggravating problem?