I'm running Apex 20.1 and I need to generate some urls that includes the checksum and the session (that's mandatory)
I'm doing :
Output := APEX_UTIL.PREPARE_URL(p_url => 'f?p=' || ApplicationAlias || ':' || PageAlias || ':' || SessionId ||'::::' || Arguments || ':' || ArgumentsValues, p_checksum_type => 'SESSION');
with :
-- for example
Arguments := 'param1,param2';
ArgumentsValue := 'value1,value2';
This command works properly but the URL is missing the session.
The URL Returned is :
https://www.example.com/ords/schema/r/myapp/pagealias?
param1=value1&
param2=value2&
cs=3BSsM-dn0SHfT0DBLYTRIHlSC_71paQVC0VQ_Hfa6YuVc-DzsnTzEs6yH
Now I need to have the session included in the URL. Means at the end of the URL I should have
&session=45654654987
I tried adding the session manually like :
Output := Output || '&session=' || v('APP_SESSION');
This works only for standard pages and not modal pages. So for modal pages I'm doing like :
-- Output generated from APEX_UTIL.PREPARE_URL :
javascript:apex.navigation.dialog(
'\u002Fords\u002Fschema\u002Fr\u002Fmyapp\u002pagealias?
param1=value1\u0026
param2=value2\u0026
cs=3_XtJdikM6ypsgs1BPNLnh3dKfHI5-gbFl0YMA78wn032WRoN8Z4PoFDOmQJ9RvaMkW1q-Uk-x9BNEaunXyY_hw\u0026
dialogCs=fC8UqaERKj1k7OONTBxSKhPe4GeVKJ4Mk0nSTNDMRIR0o5hpagnDAKoNiYHzqcWo5Q6FgikwEvkbfQBdNE7MtQ',
{title:'Page title',height:'auto',width:'720',maxWidth:'960',modal:true,dialog:null},'t-Dialog-page--standard '+'',apex.jQuery('#regionId'));
Trick to fix it :
Output := replace(Output, ',{title' , '&session=' || v('APP_SESSION') || ',{title');
That returns
javascript:apex.navigation.dialog(
'\u002Fords\u002Fschema\u002Fr\u002Fmyapp\u002pagealias?
param1=value1\u0026
param2=value2\u0026
cs=3_XtJdikM6ypsgs1BPNLnh3dKfHI5-gbFl0YMA78wn032WRoN8Z4PoFDOmQJ9RvaMkW1q-Uk-x9BNEaunXyY_hw\u0026
dialogCs=fC8UqaERKj1k7OONTBxSKhPe4GeVKJ4Mk0nSTNDMRIR0o5hpagnDAKoNiYHzqcWo5Q6FgikwEvkbfQBdNE7MtQ&
session=98798798797',
{title:'Page title',height:'auto',width:'720',maxWidth:'960',modal:true,dialog:null},'t-Dialog-page--standard '+'',apex.jQuery('#regionId'));
Is there any better way to do this please ?
Thanks.
Cheers,
Instead of using APEX_UTL.PREPARE_URL, have you tried using APEX_PAGE.GET_URL? In the APEX 21.2 documentation for APEX_UTIL.PREPARE_URL, it is recommended to use APEX_PAGE.GET_URL instead of APEX_UTIL.PREPARE_URL.
APEX_PAGE.GET_URL has a parameter to include the APEX session id so it should properly build the session id into the URL depending the type of page you are navigating to. The checksum will also automatically be generated in the URL as long as you are navigating within the same workspace as your current session.
APEX_PAGE.GET_URL will also return the URL in "friendly" syntax if "friendly URLs" are enabled for the application of the page you are navigating to.
Related
I have a process running On Submit.
At the end of the process, I am trying to update the session state of an item :P2_CASE_ID.
I am trying to assign it the value of a variable calculated in the PL\SQL.
My code at the end setting the session state is as below:
APEX_DEBUG.INFO(p_message => 'ABOUT TO CHANGE VALUE OF P2_CASE_ID, BEFORE: ' || :P2_CASE_ID);
APEX_DEBUG.INFO(p_message => 'CHANGING P2_CASE_ID TO HAVE THE VALUE OF case_ids: ' || case_ids);
APEX_UTIL.SET_SESSION_STATE('P2_CASE_ID',RTRIM(case_ids , ','));
APEX_DEBUG.INFO(p_message => 'CHANGED VALUE OF P2_CASE_ID, AFTER: ' || :P2_CASE_ID);
When I check the debug logs, the session state hasn't changed.
select * from APEX_DEBUG_MESSAGES WHERE MESSAGE like '%P2_CASE_ID%'
ORDER BY MESSAGE_TIMESTAMP DESC
Output from DEBUG:
> ABOUT TO CHANGE VALUE OF P2_CASE_ID, BEFORE: 2003,2004
> CHANGING P2_CASE_ID TO HAVE THE VALUE OF case_ids: 2006,2007,2008,2009
> Session State: P2_CASE_ID=>2006, 2007, 2008, 2009
> CHANGED VALUE OF P2_CASE_ID, AFTER: 2003,2004
The debug line starting "Session State" is not one of mine, so assume it is an output of the APEX_UTIL function to set the session state.
Use APEX_UTIL.GET_SESSION_STATE to check if it is in session state. Mixing bind variable syntax with set/get session state in the same process is not a good practice.
But... there should be no need to use APEX_UTIL.SET_SESSION_STATE within the context of your application.
:P2_CASE_ID := RTRIM(case_ids , ',');
Will work just as well and it's less typing :)
I have this line of code that only has 2 options. If it is Provider Payments then use the provider_payments_work_lists_path else use the duplicate_claims_work_lists_path. Now I want to include a potential 3rd path. if the name == "Reimbursed Claims" then path them to reimbursed_claims_work_lists_path. How can I do that? Currently I have:
url = (workList.work_list_name == "Provider Payments") ? provider_payments_work_lists_path : duplicate_claims_work_lists_path
Just use a case statement:
url = case workList.work_list_name
when 'Provider Payments'
provider_payments_work_lists_path
when 'Reimbursed Claims'
reimbursed_claims_work_lists_path
else
duplicate_claims_work_lists_path
end
Hey I am working on a password changer. User logs in ( successfully), loads a global var with user initials, then launch a password expired form. I try and use those initials on the password expired form to retrieve user info from DB.
vaUserLog.FieldValue("USERINIT") = UserInitials
vaUserLog.GetEqual
vaStat = vaUserLog.Status
vaStat keeps giving me an error of 4. I am using pervasive v9. Connection with VA looks like:
With vaUserLog
.RefreshLocations = True
.DdfPath = DataPath
.TableName = "USERLOG"
.Location = "USERLOG.MKD"
.Open
If .Status <> 0 Then
ErrMsg = "Error Opening File " + .TableName + " - Status " + str$(.Status) + vbCrLf + "Contact IT Department"
End If
End With
In DB table, USERINIT is Char, 3. UserInitials is a String.
Probably missing something small but can't think right now. Any help is appreciate. Lemme know if you require more info.
Cheers
Status 4 means that the record could not be found. In your case, it could be the case of the value being searched is wrong, there's a different padding (spaces versus binary zero), or that the UserInitials value just isn't in the data file.
You can use MKDE Tracing to see what's actually being passed to the PSQL engine. Once you've done that, make sure the value you're using works through the Function Executor where you can open the file and perform a GetEqual.
Here are my suggestions:
- Make sure you're pointing to the right data files.
- Make sure you're passing the right value into the GetEqual (by setting the FieldValue).
I am trying to put second language on my webpage. I decided to use different files for different languages told apart by path - language/pl/projects.ln contains Polish text, language/en/projects.ln - English. Those extensions are just to tell language files from other, the content is simple php:
$lang["desc"]["fabrics"]["title"] = "MATERIAŁY";
$lang["desc"]["fabrics"]["short_text"] = "Jakiś tam tekst na temat materiałów";
$lang["desc"]["services"]["title"] = "USŁUGI";
$lang["desc"]["services"]["short_text"] = "Jakiś tam tekst na temat usłóg";
And then on the index page I use it like so:
session_start();
if (isset($_SESSION["lang"])) {
$language = $_SESSION["lang"];
} else {
$language = "pl";
}
include_once("language/$language/projects.ln");
print $lang["desc"]["fabrics"]["title"];
The problem is that if the session variable is not set everything works fine and array item content is displayed but once I change and set $_SESSION["lang"] nothing is displayed. I tested if the include itself works as it should by putting print "sth"; at the beginning of projects.ln file and that works all right both with $_SESSION["lang"] set and unset.
Please help.
Can you test the return value of session_start() - if it's false, it failed to start the session.
Is it being called before you output anything to the browser? If headers were already sent and your error_reporting level is too low, you won't even see the error message.
Stupid, but - do you set value of $_SESSION['lang'] to valid value like "en"? Does the English translation load correctly when you use it as default value in else block instead of "pl"?
"Jakiś tam tekst na temat usłóg" -> "usług" :)
Can you tell us what does this one output:
if(session_start()) {
echo SID, '<br/>';
if(isset($_SESSION['lang'])) {
echo 'lang = "',$_SESSION['lang'], '"';
}
}
Session starts fine and accidentally I managed to fix it.
I renamed $_SESSION['lang'] to $_SESSION['curr_lang'] and it now works allright. It seams like it didn't like the array and session variable having the same name (?).
I need to refresh dbgrid constantly, in real time. Close and open dataset works fine, but blink the dbgrid. What can I do to avoid this?
I'd like a solution like Ajax, that update only the necessary.
Thanks
Have you tried to use Disable- & EnableControls?
DataSet.DisableControls;
try
DataSet.Close;
DataSet.Open;
finally
DataSet.EnableControls;
end;
Furthermore, it should be possible to just call DataSet.Refresh instead of closing and opening to get the same result.
I use this in my app
DataSet.MergeChangeLog;
DataSet.ApplyUpdates(-1);
DataSet.Refresh;
The above code is in an action named actRefreshData, in the ActionManager
When I need to use I just call it like
actRefreshData.Execute;
Hope this helps.
Hint: you can add a Timer and automate this
Look here:
type THackDataSet=class(TDataSet); // a nice "hack" so we can access
//protected members
THackDBGrid=class(TDBGrid);
procedure {tdmdb.}refreshgrid(grid : tdbgrid);
var row, recno : integer;
ds : tdataset;
b : tbookmark;
begin
Row := THackDBGrid(grid).Row;// or THackDataSet(ds).ActiveRecord
ds := grid.datasource.dataset;
RecNo := ds.RecNo;
b := ds.GetBookmark;
try
ds.close;
ds.Open;
finally
if (b<>nil) and ds.BookMarkValid(b) then
try
// ds.GotoBookMark(b);
ds.CheckBrowseMode;
THackDataSet(ds).DoBeforeScroll;
THackDataSet(ds).InternalGotoBookmark(b);
if THackDataSet(ds).ActiveRecord <> Row - 1 then
THackDataSet(ds).MoveBy(Row - THackDataSet(ds).ActiveRecord - 1);
ds.Resync([rmExact{, rmCenter}]);
THackDataSet(ds).DoAfterScroll;
finally
ds.FreeBookMark(b);
end
else if (recno<ds.RecordCount) and (recno<>ds.RecNo) then
begin
ds.First;
ds.MoveBy(Max(0, recno-1));
end;
end;
end;