The following code I use to navigate to the target with Route parameters:
UI.getCurrent().navigate(ViewCandidateView.class, new RouteParameters(ViewCandidateView.PROFILE_UUID_PARAMETER, profileDecisionMatrix.getDecision().getUuid()));
which correctly leads me to the following url:
/candidates/a90bd8a9-0de8-4a10-ba82-e5a059eb861e
but I also need to add the query parameter - job_id=100, something like that:
/candidates/a90bd8a9-0de8-4a10-ba82-e5a059eb861e?job_id=100
what navigate method should I use in order to be able to provide Route and Query parameters at the same time?
In your case you can use this
QueryParameters queryParameters = new QueryParameters(Map.of("job_id", List.of(100)));
navigateUI.getCurrent().navigate(
ViewCandidateView.class,
profileDecisionMatrix.getDecision().getUuid(),
queryParameters);
Related
I am using Laravel 5. In my Controller I am getting value from View like this method:
$params = array('' => Input::get("selected_category_id"));
then it showing in my log like this:
/api/zones/?=3
I try to modify which remove the single quote and equal symbol, like this:
$params = array(Input::get("selected_category_id"));
then it showing in my log like this:
/api/zones/?0=3
Can I set my url to be like this format:
/api/zones/3
thanks for any help!
As far as I understand your questions, you need to create a new route for it:
Route::post('/api/zones/{id}','YourController#processInput');
In the above route, replace YourController with the controller you are using to process the input and replace processInput with the method that actually processes it.
So, your controller would now have access to the category:
public function processInput(Request $request, $id)
{
$categoryID = $id;
}
I have a collection called customer_devices and I can't change the name. Can I expose it via deployd as /devices ? How?
There are a few ways that I can think of. If you really just want to rename the collection, you can do so from the dashboard, as #thomasb mentioned in his answer.
Alternatively, you can create a "proxy" event resource devices and forward all queries to customer_devices. For example, in devices/get.js you would say
dpd.customer_devices.get(query, function(res, err) {
if (err) cancel(err);
setResult(res);
});
Update
Finally, here is a "hack" to redirect all requests from one resource path to a different path. This is poorly tested so use at your own risk. This requires that you set up your own server as explained here. Once you have that, you can modify the routing behaviour using this snippet:
server.on('listening', function() {
var customer_devices = server.router.resources.filter(function (res) {
return res.path === '/customer_devices';
})[0];
// Make a copy of the Object's prototype
var devices = Object.create(customer_devices);
// Shallow copy the properties
devices = extend(devices, customer_devices);
// Change the routing path
devices.path = "/devices";
// Add back to routing cache
server.router.resources.push(devices);
});
This will take your customer_devices resource, copy it, change the path, and re-insert it into the cached routing table. I tested it and it works, but I won't guarantee that it's safe or a good idea...
Can't you change the name via dashboard?
Mouseover your collection customer_devices
Click the down arrow
Select 'Rename'
Enter the new name and click 'Rename'
I have two rules
Route::get('this-is-an-awesome-route', 'Ads#getIndex');
Route::controller('ads', 'Ads');
action('Ads#getIndex') renders
http://my-awesome-domain/ads
I want
http://my-awesome-domain/this-is-an-awesome-route
What's the problem ?
For some reason from Laravel 4.2 to Laravel 5 the logic changed a little bit. The line you wrote was working before, you just have to reverse everything as the router isn't processing your code the same way.
Tested and working solution
Route::controller('ads', 'Ads');
Route::get('this-is-an-awesome-route', 'Ads#getIndex');
The first route will be overwritten by the second one.
The second route is rewriting the first route declaration. Let's see:
// Ads#getIndex will be called
Route::get('this-is-an-awesome-route', 'Ads#getIndex');
// Ads#getIndex will be called too by native definition
Route::controller('ads', 'Ads');
Because of Route::controller('ads', 'Ads') is called as latest declaration it will overwrite the previous one. So, you have at least two ways to achieve this task
You could create a new function into Ads controller just to response to the first route:
Route::get('this-is-an-awesome-route', 'Ads#awesome');
Then:
public function awesome(){
// do stuff here
}
Rename the route name for your controller
Route::controller('ads', 'Ads', [
'getIndex' => 'ads.getHome',
]);
Now your Route::controller('ads', 'Ads'); will respond to getHome() instead getIndex() as per renamed route:
public function getHome(){
// do stuff for getIndex() definitions here
}
I have the follow routes to different controllers and actions, that all shows the same layout and different views, example:
http://<my domain>/controllername1/action1
http://<my domain>/controllername1/
http://<my domain>/controllername2/action1
http://<my domain>/controllername3/action1
How can I get the controller name that loads the Layout in the Layout code?, something that returns: "controllername1", "controllername2" or "controllername3"
The goal is to identify in which section I'm of my site and make some customization in layout.
I checked similar replies but are for old versions of Zend Framework.
Clarification:
The idea is to get the controller name from the Layout code, not pass it from the controller code. Maybe isn't possible? Other answers are for older versions of ZendFramework (beta versions), and maybe is a more straightforward way now.
Edited: more information
I can set in my Module.php file the follow code on onBootstrap($e):
public function onBootstrap($e)
{
// (...) Other code
$application = $e->getParam('application');
$viewModel = $application->getMvcEvent()->getViewModel();
// Parsing URI to get controller name
$viewModel->controllerName = trim($_SERVER['REQUEST_URI'],'/');
if (substr_count($viewModel->controllerName, '/')) {
$viewModel->controllerName = substr($viewModel->controllerName, 0, strpos($viewModel->controllerName, '/'));
}
}
And then from the Layout code use it as follow:
echo $this->layout()->controllerName;
The first problem is that the follow piece of code should be replaced with something (more "beautiful") using ZF2 functions to get Controller name:
(...)
// Parsing URI to get controller name
$viewModel->controllerName = trim($_SERVER['REQUEST_URI'],'/');
if (substr_count($viewModel->controllerName, '/')) {
$viewModel->controllerName = substr($viewModel->controllerName, 0, strpos($viewModel->controllerName, '/'));
}
I want to avoid inject the Controller name from all controllers/actions: that is solved by using Module.php, but maybe is a more direct way.
Thanks!
You're looking for this link: How to get the controller name, action name in Zend Framework 2
$this->getEvent()->getRouteMatch()->getParam('action', 'index');
$this->getEvent()->getRouteMatch()->getParam('controller', 'index');
Otherwise you have the same question (and answer(s)) here : ZF2 - Get controller name into layout/views
MvcEvent – get NAMESPACE / Module Name from Layout
http://samsonasik.wordpress.com/2012/07/27/zend-framework-2-mvcevent-layout-view-get-namespace/
I didn't test but it seems correct : http://pastebin.com/HXbVRwTi
I know that this is an old question but there is a simple answer that should be noted here:
$this->getHelperPluginManager()->getServiceLocator()->get('Application')->getMvcEvent()->getRouteMatch()->getParam('action')
this will return any route param, 'action' in this case.
This code can be used in view or in layout.
I would like to add an URL fragment #top to a HtmlOutcomeTargetLink, but cant figure out how. For an HtmlOutputLink I just use the following:
HtmlOutputLink link = new HtmlOutputLink();
String urlWithFragment = url + "#top";
link.setValue(urlWithFragment);
How to acomplish this for a HtmlOutcomeTargetLink?
Unfortunately the following does not work:
HtmlOutcomeTargetLink link = new HtmlOutcomeTargetLink();
String urlWithFragment = context.getViewRoot().getViewId() + "#top";
link.setOutcome(urlWithFragment);
Thanks for your help!
The outcome of HtmlOutcomeTargetLink (the <h:link>) only takes navigation case outcomes, not URLs. The navigation case outcomes do not support URL fragments. Those needs to be set as a separate fragment attribute.
link.setFragment("top");
See also:
<h:link> tag documentation
Update: wait, there's no setter for that on the UIOutcomeTarget parent class. I suspect an oversight in the generated code (funnily it's mentioned here in Mojarra snapshot docs and here in a MyFaces testcase). You should be able to set it directly on the attribute map:
link.getAttributes().put("fragment", "top");