How to access model of parent view in UI5 - model-view-controller

The view is declared this way:
<mvc:View controllerName="com.sap.my.app.controller.Edit"
xmlns:l="sap.ui.layout"
xmlns:mvc="sap.ui.core.mvc"
xmlns:bpa="com.sap.my.app.control"
xmlns:core="sap.ui.core"
xmlns="sap.m"
height="100%">
<mvc:XMLView viewName="com.sap.my.app.view.AttachmentPreview"/>
</mvc:View>
How can I access the model defined in the Edit controller within the AttachmentPrevie controller?
The AttachmentPreview will be reused inside multiple other views. Not only in Edit view.

Make you model global by declaring it in manifest.json file if possible or inside Component.js file

You can simply refer to the parent view with the method getParent() in the child view e.g. this.getView().getParent().getModel(). Please do make sure that the view itself is already attached or else the getParent would return null.

Related

Returning two views in controller class function

I am trying to return two views in Laravel controller class, but I do not know how it should be done.
I want to add an additional 'payment' view in the show function
enter image description here
Rather than rendering two views inside of the controller you should use blades #include tag. E.g.
<!-- Some Code -->
#include('components.payment', ['somedata' => $data])
<!-- Some More Code -->
See the docs for more: https://laravel.com/docs/5.8/blade#including-sub-views

Laravel 5.4 render parent view before child view

Is it possible to force laravel to execute the parent view then the child view ? I use a master view with some view composers to create a menu and set some variables, then in my sitemap subview, because the master view is computed after I end up having my menu not created yet.
#extends('layout.master')
#section('content')
{{-- Render this after layout.master --}}
#endsection
Maybe I missed some possibility here.
If you watch code that blade generate in storage/framework/views/some_name.php you can see next code:
<?php echo $__env->yieldContent('content'); ?>
It`s working something like PHP inlcude, when code come to this line it come in to this file with content.
That`s why you can not load master view and then subview.

Titanium if attribute and Alloy.Globals not working

According to the documentation it is possible to:
In the XML markup, add the if attribute to an element and assign it to the property passed to the createController() method. Prefix the property name with the $.args namespace. Based on the property passed to the method, the application displays a different label.
So this means that if I put:
<Label if="Alloy.Globals.property" color="blue">Foobar</Label
Wont work?? Right now I´m not using the createController method, because it is added on the XML by a Require tag. Is there any way to do this?
As you can see in the docs there are some examples.
One of which:
<Alloy>
<Window>
<Label if="$.args.fooBar" color="blue">Foobar</Label>
<Label if="$.args.fooBaz" color="red">Foobaz</Label>
</Window>
</Alloy>
So yes, this will just work. As long as the property you provide is already set when rendering. Once your variable changes while the view is open it won't update it. For that you'll need data binding

Joomla include view in other view

I have problem with including Joomla views. I have many views in my extension and I want to include another one in my Dialog.
How can I do it?
In my first view I have this code:
<div id="modalDostawca" title="Dostawcy">
<div id="wewM">
//in here i want to include view data/tmpl/default.php
</div>
</div>
What kind of extension is your extension? A module? A component?
If it's a component, what you are trying to include is a template for a view, not a view! (the view is the one with view.html.php). Create a view + template for what you are trying to see. I don't think Joomla! can call multiple views at the same time. If you can reuse code inside models (if this is your concern).
You can also include files the normal way, with include(...).

Html.RenderAction cannot find my controller

I have a razor masterpage (_Layout.cshtml) where I layout a 3 column website. In one of the side columns I want to display a "Login Control"
From my readings, I can use Html.RenderAction to call my LoginController and it will display the login view in the side column.
But, when I run it and point it to a Controller/View to fill the RenderBody(), the call to Html.RenderAction("Index", "LoginController") fails with this error.
"The controller for path '/[insert path to a Controller/View to fill the
RenderBody()]' was not found or does not implement IController. "
So, what am I doing wrong?
My code really is as simple as:
<div id="Navigation">#{ Html.RenderPartial("Test"); }</div>
<div id="Main">#RenderBody()</div>
<div id="Misc">#{ Html.RenderAction("Index", "LoginController");}</div>
And in my controllers folder, I have the controller for the RenderBody and the LoginController.
When specifying controller names by convention in MVC, you don't include the "Controller" part.
Html.RenderAction("Index", "LoginController")
wouldn't work unless you had a controller named "LoginControllerController"
try
<div id="Misc">#{ Html.RenderAction("Index", "Login");}</div>

Resources