Oracle APEX how do I populate cascading select lists without page submit - oracle-apex

I have an APEX page with a few select lists, using collections to save and refresh the page. The "System" select list is dependent upon the "Brand" selected value. I have the page working how I want, but it requires the page to be submitted after a "Brand" value is chosen so that the "System" lov is properly populated.
I am trying to make it so that when the "Brand" value is changed or selected, the "System" lov is changed immediately without needing a page submit. I've been reading and it seems you need to use jQuery and AJAX callback, but I just cannot get my head around that and make any progress.
Hoping someone can help me. I am certainly a rookie with web coding in general.
Added: my local APEX version is 5.0.3.
https://apex.oracle.com/pls/apex/f?p=4550
Workspace: UNCLE_BUCK_WS
User: developer1
Pwd: developer1
Application 83513 - Tooth Selector
Page 5: Page that works using submit page
Page 6: Page I started trying to use jQuery, but did not get very far
Added:
There is no cascading LOV for manual tabular form. See my region definition below. Hoping someone can still help, maybe copy my page and make the required changes.
select apex_item.select_list_from_query(p_idx => 1,
p_value => n001,
p_query => 'SELECT tooth_number display_value, tooth_number return_value FROM psp_teeth WHERE tooth_numbering_method = :P5_TOOTH_NUMBER_METHOD
ORDER BY tooth_number',
p_null_text => '- Choose Tooth -')
|| apex_item.hidden(p_idx => 50, p_value => seq_id) Tooth_Number
, apex_item.select_list_from_lov(p_idx => 10, p_value => c001, p_lov => 'BRAND', p_null_text => '- Choose Brand -') brand
, apex_item.select_list_from_lov(p_idx => 12, p_value => c002, p_lov => 'TYPE', p_null_text => '- Choose Type -') type
, apex_item.select_list (p_idx => 14,
p_value => c003,
p_list_values => CASE c001
WHEN 'BRAND_A' THEN 'SYSTEM_A1,SYSTEM_A2'
WHEN 'BRAND_B' THEN 'SYSTEM_B1,SYSTEM_B2'
END,
p_show_null => 'YES',
p_null_text => '- Choose System -') system
, apex_item.checkbox2(p_idx => 16, p_value => seq_id, p_checked_values => CASE c004 WHEN '1' THEN seq_id END) delete_row
from apex_collections
where collection_name = 'TEMPCOL'

Don't use tabular forms, they are archaic! Use an Interactive Grid instead, which supports cascading LOVs declaratively (you don't need to write any code, just specify that column TYPE cascades from column BRAND):
See page 9 in your app where I have created one (I didn't bother creating the master region). My LOV definition for TYPE is a bit cumbersome, you may be able to improve on that (i.e. get back to the "dynamic static" LOV that you had before).

Related

WP_Query meta_query REGEXP

I am pretty much below beginner level for REGEX/REGEXP and have hit a blocking point in a project I am working in, where I am trying to get the ids for posts that match the search criteria , but I want to restrict the search between 2 sub-strings. I am trying to figure out is how to write the REGEXP in the meta_query:
$args = array(
'post_type'=> 'custom',
'order' => 'DESC',
'posts_per_page' => 10,
'paged' => $page,
'meta_query' => array(
array(
'key' => 'key',
'value' => "title*".$search."*_title",
'compare' => 'REGEXP',
)
),
);
And an example of the field in the DB :
a:302:{s:5:"title";s:10:"Test title";s:6:"_title";s:19:"
Unfortunately none of the combinations I tried based on documentation of SQL REGEXP won't return any values and I am trying to understand how I can pull this off and would appreciate any input.
Also would rather stick to WP_Query for now even though an SQL LIKE "%title%{$search}%_title%" works perfectly , so an alternative solution would be how to set the compare to 'LIKE' and parse it '%' since that is not possible out of the box as the % get escaped I believe.

Can't see custom attributes set on a user from their Google_Service_Directory_User object

When a custom attribute is set on a user from googles admin page I am unable to see it in their Google_Service_Directory_User object the client has this scope and is able to see the users data but no attributes are shown.
$client->setScopes(
[
Google_Service_Directory::ADMIN_DIRECTORY_USER_READONLY,
Google_Service_Directory::ADMIN_DIRECTORY_GROUP_READONLY,
]
);
I would have expected it to be in the customSchemas but that is null for all the users
When requesting user's informations, you need to set the projection parameter to FULL when using the method users.get (projection parameter is also avaible with method users.list). Default settings to not return custom schemas. You can have more informations here (Google documentation).
You seem to be using PHP (I've never coded in PHP so I may be wrong), so the request should look like this:
$optParams = array(
'userKey' => 'my_customer#example.com',
'projection' => 'full', // or maybe 'FULL' ?
);
$results = $service->users->get($optParams);
If you only want the return some of the schemas, then use :
$optParams = array(
'userKey' => 'my_customer#example.com',
'projection' => 'custom', // or maybe 'CUSTOM' ?,
'customFieldMask' => 'A comma-separated list of schema names'
);
$results = $service->users->get($optParams);

How do I programmatically restore an Apex 5 report to default state?

I have an Interactive report in Apex 5, and each time the page load, I want it to look exactly as it was shown the first time I ran it, with default settings.
The problem is that if the user applies any filter, or hide columns, the next time the page loads, the report remembers that configuration.
I tried to use the APEX_IR.RESET_REPORT procedure undocumented here:
https://docs.oracle.com/database/121/AEAPI/apex_ir.htm#BABEJAFB
but it either doesn't works, or only undoes the last change, or needs many runs to actually work.
I tried a dynamic action at page load with this code:
DECLARE
v_region_id APEX_APPLICATION_PAGE_REGIONS.REGION_ID%TYPE;
BEGIN
SELECT region_id INTO v_region_id
FROM APEX_APPLICATION_PAGE_REGIONS
WHERE application_id = :APP_ID
AND page_id = :APP_PAGE_ID
AND static_id = 'Images_Report';
APEX_IR.RESET_REPORT(
P_page_id => :APP_PAGE_ID,
P_region_id => v_region_id,
p_report_id => null
);
END;
And I also tried this code
DECLARE
v_region_id APEX_APPLICATION_PAGE_REGIONS.REGION_ID%TYPE;
BEGIN
SELECT region_id INTO v_region_id
FROM APEX_APPLICATION_PAGE_REGIONS
WHERE application_id = :APP_ID
AND page_id = :APP_PAGE_ID
AND static_id = 'Images_Report';
APEX_IR.RESET_REPORT(
P_page_id => :APP_PAGE_ID,
P_region_id => v_region_id,
p_report_id => APEX_IR.GET_LAST_VIEWED_REPORT_ID(
p_page_id => :APP_PAGE_ID,
p_region_id => v_region_id
)
);
END;
I expect the report to look as in default state (on first run), every time I load the page.
Instead the report shows the last state, even if the user logs out, logs in and restarts the application.
Send RIR as the clear cache parameter in your URL
https://docs.oracle.com/database/apex-5.1/HTMDB/linking-to-interactive-reports.htm#GUID-B917CEB3-A0B9-414B-A90A-7B44DD15EA67
URL would look like
f?p=102:94:6722612001859::NO:RIR::
https://docs.oracle.com/database/apex-5.1/HTMDB/understanding-url-syntax.htm#HTMDB03019
The documentation states this regarding the apex_ir.reset_report procedure
This procedure should only be used in page submit processes.
Which could be why you had trouble

Unable to get text value in hybrid app using Calabash

We have a hybrid app built using Cordova and it has a login user and password field. The applicatio is developed based on EmberJs stack. We are using Calabash 1.* version and other components works fine except all text boxes.
I am able to successfully query the input elements using the below code in console.
query("systemWebview css:'input'")
I get the below query result in console. But text value is always empty even if I enter some value.
{
"class" => "ember-view ember-text-field",
"nodeType" => "ELEMENT_NODE",
"id" => "ember555",
"textContent" => "",
"html" => "<input id=\"ember555\" class=\"ember-view ember-tex
ld\" placeholder=\"Enter User name\" type=\"text\">",
"rect" => {
"y" => 202,
"x" => 0,
"center_x" => 360,
"height" => 74,
"width" => 720,
"top" => 76,
"left" => 0,
"center_y" => 238
},
"nodeName" => "INPUT",
"webView" => "NoResourceEntry-100"
},
In the Ruby section, I have the below code and it also returns empty value.
query(objectName, :textContent).first
Any help is appreciated. Thanks in advance.
Code
query "UIWebView", :calabashStringByEvaluatingJavaScript => "document.querySelectorAll('input#ember555')[0].value"
Explanation
Breaking it down,
1.
query "UIWebView",
Gets the webview.
2.
:calabashStringByEvaluatingJavaScript => ...
This is a selector which calabash-ios-server adds to webviews such that any webview (UIWebView or WKWebView) should respond to it. The selector is invoked on the result of query "UIWebView"
3.
"document.querySelectorAll('input#ember555')[0].value"
This is a standard javascript selector that you can tweak as necessary to get your element. E.g., you could use document.getElementById() or whatever is most convenient. This string of javascript is used as an argument to the calabashStringByEvaluatingJavaScript selector.
I realize it would be nice to have the text just returned as part of the object, I'll check with the team and see if we should file an issue (or, feel free to file one yourself at https://github.com/calabash/calabash-ios-server/issues ).
Thanks to #christoper, I found some working solution for android.
evaluate_javascript("systemWebView", "return document.getElementById('nicknameid').value;")
The same logic works for checkbox validation too.

Google Charts Axis Label Issues Line Chart

I am creating google charts to show Google Analytics data from the past 7 days. I have an issue with the X-Axis labels stacking on top of each other when I have certain data (or at least that's all I can tell is different.)
I am generating the API call using this gem: https://github.com/mattetti/googlecharts and I've looked at what each part of the URL is doing and can't find the issue, but I'm sure I'm missing something.
Here is an example of two sites data over the same time period, the first one shows the issue and the second one is a working example:
Here is the URL, these are text encoded for readability, but it has the same issues when switched to simple or extended encoding:
BROKEN VERSION:
https://chart.apis.google.com/chart?chxl=0:|11-22|11-23|11-24|11-25|11-26|11-27&chxt=x&chco=58838C,BF996B,BF5841,A61C1C&chf=bg,s,ffffff&chd=t:979,807,681,653,580,509|822,724,602,562,519,455|540,409,381,375,336,301|307,156,173,176,155,133&chds=0,979&chdl=Visits|Visitors|New+Visits|Organic+Searches&chtt=Google+Analytics+-+Last+7+Days&cht=lc&chs=600x200&chxr=0,979,979|1,822,822|2,540,540|3,307,307
WORKING VERSION:
https://chart.apis.google.com/chart?chxl=0:|11-22|11-23|11-24|11-25|11-26|11-27&chxt=x&chco=58838C,BF996B,BF5841,A61C1C&chf=bg,s,ffffff&chd=t:1385,1395,981,947,863,731|1083,1222,832,715,690,546|580,566,427,413,387,329|247,151,151,171,162,135&chds=0,1395&chdl=Visits|Visitors|New+Visits|Organic+Searches&chtt=Google+Analytics+-+Last+7+Days&cht=lc&chs=600x200&chxr=0,1385,1395|1,1083,1222|2,580,580|3,247,247
The chxr values were incorrect. The gem was generating them for multiple axes when it should have only been generating them for one. I manually overrode the min, max and step in the gem and it worked.
Here is my code using the gem, first getting the max value from all my data points:
[#visits,#visitors,#new_visits,#organic_searches].each do |array|
array.values.each do |value|
#max_value = value if (value > #max_value)
end
end
# Chart it
chart = Gchart.line(
:title => prop.to_s.upcase + ' Google Analytics - Past 7 Days',
:size => '600x200',
:bg => 'ffffff',
:axis_with_labels => ['x'],
:axis_labels => [#visits.keys],
:legend => ['Visits','Visitors','New Visits','Organic Searches'],
:line_colors => ['58838C','BF996B','BF5841','A61C1C'],
:encoding => 'text',
:data => [#visits.values,#visitors.values, #new_visits.values, #organic_searches.values],
:max_value => #max_value,
:axis_range => [nil, [0, #max_value, (#max_value / 10).to_i]],
:format => 'image_tag')