if i have this module structure:
ModuleA
*View/View_A
*Controller/ControllerA
ModuleB
*View/View_B
*ViewModel/ViewModel_B (view model for View_B)
*Controller/Controller_B
how could ControllerA use UriQuery to display View_B in a region
inside View_A
how could controllerB use UriQuery to display View_B in a region
inside View_A
which is better for displaying View_B in a region in View_A
Thanks in advance
I am not sure if I answer your question exactly. But I would recommend you to take a look at the Sample project that came with Prism2.2 -> Quickstarts - > UI Composition -> View Injection. This uses Unity and the example is in Silverlight and WPF.
This has the sample of how you can show the view from different module. It does not call the controller of the other project but calls the presenter.
IProjectsListPresenter projectsListPresenter = this.container.Resolve<IProjectsListPresenter>();
projectsListPresenter.SetProjects(employee.EmployeeId);
IRegionManager detailsRegionManager = detailsRegion.Add(detailsPresenter.View, employee.EmployeeId.ToString(CultureInfo.InvariantCulture), true);
IRegion region = detailsRegionManager.Regions[RegionNames.TabRegion];
region.Add(projectsListPresenter.View, "CurrentProjectsView");
detailsRegion.Activate(detailsPresenter.View);
Use the activate method to activate the view. Or if it is specific requirement/need to navigate, you can use detailsRegionManager.RequestNavigate with the UriQuery. (I have not tried request navigate myself :)
Additionally please review this post
http://compositewpf.codeplex.com/discussions/402860#post940396
Hope this helps.
Good Luck!
Related
I'm still learning GWT, yet already have to face some kind of challenge for a work I have to do. Can't show any specific code so I'll try to explain it well.
Here's the situation: A certain class "Navigator" creates and save the Presenter instances of my architecture to allow reusing them. There is a method show() inside that same class that actually displays the view related but that system only works full screen by calling RootPanel.get().
What i'd like to do is showing that presenter instance's view inside of a flex panel element declared in a class myView (related to a class myPresenter) that basically uses Flex Panel to structure it's content.
To make it maybe more clear:
class myView{
...
flexPanel.setWidget(firstWIdget)
flexPanel.setWidget(secondWidget) //secondWidget to be replaced by a "thirdWidget"
...
}
I'd like the secondWidget to be replaced by another one, let's call it thirdWidget, that consists of a specific presenter instance's view.
To resume, I'd like my presenter instance's view to not go full screen but only occupy a certain area of the screen.
The displaying is managed almost entirely programmatically, means very limited use of css files and no use at all of xml ui files.
How can I manage this ?
Thanks
Use a SimplePanel as a container for your views returned by your Navigation class instead of adding them directly to root panel, and use that instance of SimplePanel where ever you want.
if I want to add for example the mouse event "setOnMouseEntered" to my code and I already have a viewer, controller, model and main. Where do I put this method in?
Because if I search for examples, this methos is written in the start-method. In my case it would be in the main class? Actually have kind of a scene styler in the viewer.
Thanks!
do you search for something like this?
https://github.com/StefanHeimberg/javafx8-spielwiese/tree/master/example-fullscreen-fade/src/main/java/example/menubar.
in the menubar.fxml (VIEW) i used the onAction="#handleImage2LongRunningAction" and fx:controller="example.menubar.MenubarPresenter" (CONTROLLER)
then on the presenter i called some service (MODEL / Business Logic)...
I'm making a search for joomla, after clicking search button I am getting this url:
index.php?searchword=aa&task=search
How can I create a view or task for it?
If you use the basic joomla search component you will find the views in
/components/com_search/views/search/tmpl
If you edit the view then its advisable to use template overrides, to ensure you will not lose your views on upgrade : http://docs.joomla.org/How_to_override_the_output_from_the_Joomla!_core
addition :
If you are building a component and you want a task to execute like that, then use this in your YourComponentName.php.
$controller = JController::getInstance('FrontendSuite');
$controller->execute(JRequest::getVar('task'));
$controller->redirect();
And add the task as a function in your controller.php. You will get something like this :
function search(){
$searchword = JRequest::getVar('searchword');
//Do your magic
}
As Valentin pointed out just below, you will need to add option=com_yoursearchcomponent to your URL for Joomla to call your component.
Adding Views to your component is explained quite well in the link Valentin posted below, http://docs.joomla.org/Developing_a_Model-View-Controller_Component/2.5/Adding_a_view_to_the_site_part
Hope this helps,
Good luck
Your URL will be like:
index.php?option=com_yoursearchcomponent&task=search&keyword=xxx
So you need to create a component. Have a look at the Developing a Model-View-Controller Component.
Then you will have in your controller or subcontroller the task search which will call the view search, where you will have the appropiate template for the view.
Sorry about the question title, but I couldn't find a more appropriate way to phrase this.
I am currently building a CakePHP powered website and I'm not quite sure how to approach the following issue. The website looks something like the follwing mockup:
.
The greyed out areas are part of the layout, because their content does not change between views. In the sidebar, I have a collection of ads who are linked to several models. I need controller logic to determine the picture associated with an ad. Also, the ad list needs to be dynamic. Where should I put the logic for building the sidebar?
I've thought about:
putting the logic into the AppController (beforeFilter / afterFilter) - the problem is I can't use the controller logic I need (the other controllers inherit from AppController, I'm not sure how to use them there).
making a component - is it okay to build components that rely on controllers?
replicating the sidebar code in all controllers that render views - this seems kind of stupid to me.
What is the Cake way for this?
Update
After some reading and experimenting, I've gotten to refactoring most of it.
I obtained the best performance by moving the logic for building my ads in the model (eliminating the component that retrieved the pictures) and not using requestAction. It's almost three times faster and the code looks much better.
I've done something similar for data-driven navigation. I put my logic in AppController::beforeRender and haven't had any problems. I'm not sure I understand your concern related to controller inheritance. I retrieve my menus via:
$menus = $this->NavMenuItem->groupByMenu();
$this->set( compact( 'menus' ) );
I then created an element that renders the menu. It's executed by the layout via:
<?php echo $this->element( 'navigation', array( 'id' => 'secondary', 'menu' => $menus['SECONDARY'] ) ) ?>
If that doesn't help, maybe you can further explain your issue with controller inheritance in a comment.
I guess the answer is requestAction in case the results are cachable:
http://book.cakephp.org/view/434/requestAction
It can be done in this way:
Create an element that will help in layout of the Ad Block
Create one or more controller that will generate the data required for rendering of the block
Use requestAction for getting the data out of the models and into the element.
Check the cake book, there is an example of an element where data from Post Model is used to display top/latest 5 posts. Your requirement, I feel, is very similar to it.
Alex,
you're getting a SQL error because the build() function has to be in the Sidebar model, not controller. Also, you don't necessarily need to use $user = array('Sidebar'); you could calling Sidebar in all of your models with this:
$Sidebar = ClassRegistry::init('Sidebar'); and then $Sidebar->find();, $Sidebar->build(); etc.
Or, if you only need to call the build() function from the Sidebar model, you could do this:
$sidebar = ClassRegistry::init('Sidebar')->build();
$this->set('sidebar', $sidebar);
Cheers.
I have a region named "ActiveModule" and want to re-use it with different views, for example you press the search button and I show the search view in there, etc. etc.
The only way I can ATM do that is to deactivate all the active views in that region and then activate the view I like, this is a bit dirty, is there a "viewManager" or something similar I can use?
If your region is a ContentControl or derives from ContentControl, then there can only be one active view at a time, and you only need to activate the search view on the region.
Did you consider to use a type of contentControl that is able to show multiple views?
For example you can use a TabControl like this:
<TabControl Name="MainRegion" Regions:RegionManager.RegionName="MainRegion"/>
You can now add more than one view to the region. Use INavigationAware and IActiveAware interfaces from Prism to be able to do navigation on the views (activate them, find the correct view etc.).
If you are using a IRegionManager, you can remove all of the views whose types you recognize and then add your own.
foreach (var view in _regionsManager.Regions["MyRegion"].Views.ToArray())
{
if (view is MyType ||
view is MyOtherType)
_regionsManager.Regions["MyRegion"].Remove(view);
}
_regionsManager.AddToRegion("MyRegion", typeof(MyView));
Its by no means ideal, but it works. :)
To my knowledge what you are doing is the only way, theoretically in SCSF the top most view was activated by the framework. You could create ur own ViewManager or a ShowViewService equivalent to get this done. MAtter of fact, thats what i have done!
Not sure how you laid out your framework but if you are using navigation related framework you can simply call
regionManager.RequestNavigate(RegionNames.MainContentRegion, new Uri("your target view" + parameters, UriKind.Relative));
the above line will take care of deactivating other views in the region.
Otherwise if you do view discovery or view injection you can use the approach here
region.Activate(view);