Hello i have a question how to pass data from one view to other in mono-touch, for example i have a project with two views (view1, view2).
Both views has Textfields and i want to write something to textfield1 of view1 and when i navigate to view2 the textfield2 of view2 has to take the value of textfield1.
Create a public property on View2 and call it MyTextValue. When View1 instantiates View2, it can pass the value in by setting that property (you could also do it through an overloaded constructor).
Related
I'd like to have the layout reflect some data from a model. However, the render method from the CController class passes the structured data only to the view file, while the layout file only gets the rendered view passed.
So, how to best have the layout display data from a model?
Two possibilities come to mind:
Make Yii's layout file a no-op, mimicking layout logic manually from the view.
Override CController's render method in its subclass.
I'm not so happy with either variant, so maybe someone has a cleaner idea on how to do it?
Another way is to define a public variable in your controller class, something like:
class MyController extends Controller {
public $test = 'foo';
....
That value can then be accessed within a layout:
echo $this->test;
And manipulated in an action:
public function actionMyaction(){
$this->test = "bar";
...
Obviously it's not ideal if you have many variables that you need to use in a layout. One solution is to use an array of parameters. Alternatively you could look at making your layout more minimal and using CWidget to create reusable components for use inside your views.
For example, you obviously wouldn't want to have the code for your main navigation duplicated inside every view, so the obvious solution is to have in the layout, but if it becomes inconvenient to handle the data you could have an instance of a widget that renders out the navigation inside each view (and you can pass data to the CWidget class) something like:
$this->widget("MainNavigation",array("params"=>$params));
I am using a dynamic view panel along with a customizer bean (as demonstrated by Paul Calhoun on NotesIn9 back in episode 79 https://www.youtube.com/watch?v=AQOGgVZpAcw).
The customizer bean is currently very simple, just to ensure the documents are opened in read mode :-
public void afterCreateColumn(FacesContext context, int index,
ColumnDef colDef, IControl column) {
//Get a map of the session variables to read the view session scope variable
Map svals = context.getExternalContext().getSessionMap();
//Create a variable for the current component
UIComponent columnComponent = column.getComponent();
//Create a reference to the column and set the links to open in read mode
DynamicColumn dynamicColumn = (DynamicColumn) columnComponent;
//To have every view open the selected documents in read mode add the following
dynamicColumn.setOpenDocAsReadonly(true);
super.afterCreateColumn(context, index, colDef, column);
}
The dynamic view panel currently shows the first non-categorised column as a link to open the document. Can I add further customisation to show other columns as links, either instead of or as well as the first column?
Yes - you should be able to do this in a couple ways. The way I've done it in my customizer bean before is to handle it when fetching the column information at the front, since the goal of the bean is to match the view's design as closely as possible.
In your code there, though, you could also call dynamicColumn.setDisplayAs("link") or dynamicColumn.setDisplayAs("text") as appropriate to turn on or off link display.
I have 2 domino views bound to an xpage. view1 and view2.
In a repeat control I would like to calculate to which view I want to bind the repeat control.
In the repeat control, data, value , you have for example # view1 ,(as data source) if you don't calculate anything.
When I use ssjs and I return view1 , it's not working.(the repeat control doesn't bind to view1)
What do I have to return in ssjs to bind the repeat control to view1 ?
The value of the "view1" variable from a view data source is a little unusual, in that the binding to a repeat/view/etc. deals with the data source as it is, while the value in an SSJS context is the lotus.domino.View object itself, which is different.
In any event, though you CAN compute the repeat's binding on page load (by using page-load-sexecuted SSJS to return a value binding string, e.g. value="${javascript:'#{' + (someCondition ? 'view1' : 'view2') + '}'}"), you'd probably be better off computing the viewName property of the view data source instead. That should behave a bit more like you'd expect.
I am trying to use SplitView in order to show the information about employees. There is a list of departments in the Master part. The list of employers working in the chosen department needs to be shown in the Detail when clicking on the department.
I am using CoreData with two Entities: "Department" and "Employee" that are connected with “to-many” relation.
How should I do it?
Thanks
This is a simplified overview, since you asked a very broad question.
Create a UITableViewController subclass to be your Master view. It should have a property of type NSManagedObjectContext, and it should handle fetching and displaying the departments. (You could fetch them in loadView, or you could use an NSFetchedResultsController…)
Create another UITableViewController subclass to be your detail view. Give it a property of type NSManagedObjectContext, and also a property of type Department. Make it display the employees for that department. You'll want to make it reload its data whenever the department property changes.
Add a property to your master view controller, to refer to the detail view controller (so a property of type EmployeeViewController, or whatever you called it). Then in tableView:didSelectRowAtIndexPath: in your master view controller, set self.employeeViewController.department = <selected department>.
Create the split view controller. If this is the top level view of your application, you'll want to create it in your app delegate, otherwise create it in the view controller that pushes it to the stack. Here's how to do it (in pseudocode):
Create a new detail view controller
Set its managedObjectContext property
Create a new master view controller
Set its managedObjectContext property
Set the master view controller's employeeViewController property to your detail view controller
Create a new split view controller
Set the split view controller's viewControllers property to an array containing your master and detail view controllers
Get the split view controller on the screen somehow, either by pushing it onto the navigation stack or setting it as your root view controller in applicationDidFinishLaunching:.
I have a simple view containing a richtextbox and a button. I want to enter text into my RTB and on clicking my button have viewmodel print the RTB.
I have my command set up from the views print button and in my viewmodel have a UIElement property.
My question is how do I bind the RTB directly to my UIElement property in viewModel?
I'm fine with hooking individual properties of the RTB up but what about the whole control?
Not certain how you might accomplish that using databinding, how about just setting the reference manually?
MyControl.Loaded += (s, e) => {
((ViewModel)MyControl.DataContext).UiElementProperty = MyControl;
};
... although I'm not sure why you want to perform a task like that in the VM. How about just handling it in the view? Otherwise you might also encounter "dialogue must be user initiated" type errors.