I am using $this->redirect to redirect from one action to another
$this->redirect(array('site/payment','bookingID'=>$bookingID,'orderID'=>$model->quoteNo,'amount'=>$rent));
But I don't why it showing parameter in url
https://www.siteurl.com/bookingID/5/orderID/123456/amount/220.00
How do I hide my data from user?
You can do it using sessions. You can access current Session with Yii::$app->session. You can send those parameters in session.. For Example
public function actionOne() {
// Check if the Session is Open, and Open it if it isn't Open already
if (!Yii::$app->session->getIsActive()) {
Yii::$app->session->open();
}
Yii::$app->session['bookingID'] = $bookingID;
Yii::$app->session['orderID'] = $model->quoteNo;
Yii::$app->session['amount'] = $rent;
Yii::$app->session->close();
$this->redirect(['site/payment']);
}
public function actionTwo() {
// Then you can get those values like this...
$bookingID= Yii::$app->session['bookingID'];
$orderID= Yii::$app->session['orderID'];
$amount= Yii::$app->session['amount'];
// do whatever you want..
}
Related
I am forming a web app in lightning Community Experience Builder using LWC, which already has an URL that carries the domain of my org.
Now I want to handover the URL to users along with an Id appended to its end, such that when the user visits the site I can retrieve the Id from URL using JS.
example,
the original URL: cs-123.aig.lightning.force.com/form
User lands with: cs-123.aig.lightning.force.com/form?userId=123
I must be able to retrieve the userId when the component loads using renderedCallBack or connectedCallBack.
Thanks in advance.
Note:Lightning Navigation Service offered by LWC,doesnt work outside Salesforce,LEX.
Plain JavaScript URLSearchParams should be enough. I have something similar on my project and works ok in community, with LWC embedded on the page.
connectedCallback() {
// Try to read the preselected id from URL
if (window.location.href) {
try {
let url = new URL(window.location.href);
let id = url.searchParams.get('id');
if (id) {
this.userId = id;
}
} catch (e) {
if (console) {
console.log(JSON.stringify(e));
}
}
}
}
I am implmenting the angular router in the hybrid mobile application.(Upgrading from ionic 3 to 4). One my scnerio, I want to pass the method as a query parameter to another page. For example, Call the page "studentEditPage" from "Student Detail Page" and passing the "Update" method name to student edit page. Before poping the "StudentEditPage", it calls the update method then pop. I am tring to pass the method in the queryparam in navigate but it does not accept it in ionic 4. Are we able to pass the method as a param in the queryparameters
From StudentDetailPage
let navigationExtras : NavigationExtras = {
state : {
param : { detail: "editcategory", value: studentName, callback: this.updateStudentCallback, }
}
}
that.router.navigate(['studentDetailsPage'],navigationExtras); Here "this.updateStudentCallback" as a method.
From StudentEditPage:
this.updateStudentCallback(tempEmpData).then(() => {
this.navigate.router(['studentEditPage'])
});
I have googled and searched the angular posts but unable to get the proper results. THanks in Advance.
Well you can id like this:
where you want send/pass id/param put id here on the app-routing.module.ts file
{ path: 'studentedit/:sid', loadChildren: './studentedit/studentedit.module#StudentEditPageModule'},
then in html file
<h1 (click)="gotoUpdate(std.studentID)" >click</h1>
in ts file
gotoProductlist(studentID: string) {
this.navCtrl.navigateForward('/studentUpdate/' + studentID);
}
in Edit Page
ngOnInit() {
// Get the ID that was passed with the URL
let id = this.activatedroute.snapshot.paramMap.get('sid');
}
Well you can get id from another page.
I'm trying to read in a Google sheet my Twitter timeline.
I've copied the following code reported in the GAS documentation about twitter authentication (omitting step 2 since I'm not using the code inside a UI):
function getTwitterService() {
// Create a new service with the given name. The name will be used when
// persisting the authorized token, so ensure it is unique within the
// scope of the property store.
return OAuth1.createService('twitter')
// Set the endpoint URLs.
.setAccessTokenUrl('https://api.twitter.com/oauth/access_token')
.setRequestTokenUrl('https://api.twitter.com/oauth/request_token')
.setAuthorizationUrl('https://api.twitter.com/oauth/authorize')
// Set the consumer key and secret.
.setConsumerKey('mykey')
.setConsumerSecret('mysecret')
// Set the name of the callback function in the script referenced
// above that should be invoked to complete the OAuth flow.
.setCallbackFunction('authCallback')
// Set the property store where authorized tokens should be persisted.
.setPropertyStore(PropertiesService.getUserProperties());
}
function authCallback(request) {
var twitterService = getTwitterService();
var isAuthorized = twitterService.handleCallback(request);
if (isAuthorized) {
return Logger.log('Success! You can close this tab.');
} else {
return Logger.log('Denied. You can close this tab');
}
}
function makeRequest() {
var twitterService = getTwitterService();
var response = twitterService.fetch('https://api.twitter.com/1.1/statuses/user_timeline.json');
Logger.log(response);
}
but I obtain the message error: Service not authorized. (row 292, file "Service", project "OAuth1").
What's wrong?
I needed to add the following line the first time I execute makeRequest:
var authorizationUrl = twitterService.authorize();
Logger.log(authorizationUrl);
Then, open the url read from the log and authorize the app.
After that, all works fine.
The xpages contain SAVE button. The xpages also contain InternetAddres field.
When user click SAVE button, need to check first on names.nsf
- Save success if InternetAddress value NOT found in names.nsf view "($Users)"
- Save fail if InternetAddress value found in names.nsf view "($Users)"
How to write the script to do that?
This is the LotusScript version of script:
Set namesview = namesdb.GetView( "($Users)" )
Set namesdoc = namesview.GetDocumentByKey( Lcase(doc.CurrentInternetAddress( 0 ) ), True )
If ( namesdoc Is Nothing ) Then '-- Create New Doc
How to move on xpages?
The latest release of the OpenNTF Domino API adds a checkUnique() method to the View class. It takes two parameters, the first being a key to check against the view (e.g. a String or List of Strings), the second being the current document. After all, if you're checking for a pre-existing document, you don't want to fail just because it finds this document in the view.
So assuming CurrentInternetAddress is a single value field, the code would be:
function continueWithValidUser(namesDB, doc) {
var success = false;
try {
var view = namesDB.getView("($Users)");
success = view.checkUnique(doc.getItemValue("CurrentInternetAddress"),doc);
} catch (e) {
print(e.message);
}
return success;
}
OpenNTF Domino API recycles all handles to Domino objects, so the recycle() calls aren't needed.
In your datasource is a querySave event. You write JS there. It is almost the same code. Just with { } and ;
Remarks:
your app will break when there is more than one address book, so you you would want to use #NameLookup which is quite fast and checks all addressbooks.
unless you need the document getEntry is faster than getDocument
In SSJS your function would look like this:
function continueWithValidUser(namesDB, addressCandidate) {
var success = false;
try {
var view = namesDB.getView("($Users)");
var doc = view.getDocumentByKey(addressCandidate);
success = (doc != null);
doc.recycle();
view.recycle();
} catch (e) {
print(e.message);
}
return success;
}
That should do the trick
i pass a parameter to a page, and retrieve using the data-url attribute, it works fine. But, if i refresh that page, the url parameter will not be available. What should be done for this. Pls help.
You could store the url parameter in HTML5's localStorage. Generally, localStorage is supported by all browsers (including mobile) except IE, where it has some stability issues.
To store the url parameter,
window.localStorage.setItem("param", yourParam);
Then later, check if the item exists in the localStorage, if yes, get it from there and use.
if(window.localStorage["param"] != undefined)
{
var param= window.localStorage["param"];
}
Full workflow
var param = "", local = window.localStorage;
if(local["param"] != undefined)
{
param = local["param"];
}
else
{
//store the param in a database/in the server session and retrieve from there.
param = getFromServer();
//set item in localStorage
local.setItem("param", yourParam);
}
For more info, go to this link
The workaround for this issue is to check whether the data("url") contains a question mark ?. If not you can retrieve the parameter values from the window.location.href.
This code:
$.mobile.changePage('car-details.html', {
data: {
id: 'my_id'
}
});
creates the URL: .../car-details.html?id=my_id
The below code handles the case of normal transition and the case of page refresh. In case of page refresh the parameter value is retrieved from window.location.href
var passedId = (($(this).data("url").indexOf("?") > 0) ? $(this).data("url") : window.location.href ).replace( /.*id=/, "" );
For a complete example check this StackOverflow answer