I'd like to launch multiple HTMLViewer controls. Each should be manage its own cookie storage. If HTMLViewer_1 is already logged in on a site, e.g. HTMLViewer_2 should be able to log in using another role.
Q: How to I isolate HTMLViewer instances against each other?
If I understand your question correctly, I think you should sub-class the HTMLViewer so that the subclassed control can be customized to handle cookie storage (a Property of type Dictionary?) and other custom Methods for any required handling.
Subclassing makes any customized logic or data you add to the HTMLViewer self-contained, when the subclassed control is then added to your UI. A subclassed custom control can be reused multiple times, where each occurrence is a separate instance (with its own internal data).
If you design your new subclassed capabilities well enough, you can hide (Private scope) or encapsulate complexity (new Public Methods) to help make each future use of your subclassed control much easier.
If you're not familiar with subclassing in Xojo, maybe this link can help UserGuide:Subclassing Examples. Also checkout Xojo's YouTube series, there is an example of subclassing a Canvas. Canvas is of course a different control than HTMLViewer, but the actions required in the IDE are basically the same.
Related
I'm a newbie to iOS and now trying to design an app for multiple roles who can log in from home page.
At first, I tried to give each role a completely separate line of its own view controllers. But later, I found a lot of interfaces and codes are the same among different roles and it will be a huge amount of work to copy and paste.
So now, I try to have only one major line of view controllers and then capture the user identity to change the display (hide and unhide functions) according to different roles. But I'm not sure if this is the real preferred way to handle this kind of multirole application?
(If my question is not clear, please tell me!)
Thanks!
have only one major line of view controllers and then capture the user identity to change the display (hide and unhide functions) according to different roles.
This is the most efficient way to do this, because that way you don't repeat yourself. Having too much code (view controllers) for just small changes will create unnecessary clutter, both code-wise and space-wise.
Even if you are a newbie, try to implement best practices wherever you can, because people generally get used to what they did when they were new, and changing how you write code when you are more experienced is much harder.
First you are new to iOS.Now you are going to develop application with
multiple roles like Register,Login,Showing List,Edit
Page,Settings.....etc.If you are a newbie you can create separate view
controller for above thing.If you want to use string,id,number,...or
anything globally you can create singleton class for access that.If
you gain experience or If you get more knowledge,you can create common
view controller and class for accessing functions,variables in whole
project.Now you must learn basic things for creating application and
use without any error,crash.Learn all basics first.
I got a question that i'm trying to figure out.
How can i set 2 different Subclasses in 1 UITextField?
I have installed a library ShowPassword(via cocoapod) and currently i'm using it so users can see the password that they are typing.
But i have also installed another library that makes an awesome UITextField (also via cocoapods)
https://github.com/raulriera/TextFieldEffects
And with this library i can insert Subclass Hoshi for example (which i have done in username text field)
How can i import both of them in password textfield?
You cannot!
What you would need to be able to to is create a new class which inherits from both the TextFieldEffects and the ShowPassword. But Swift (same as Objective-C) does not support multiple inheritance (see this answer).
Your only option is to create a custom subclass from one of the classes and create the effect of the second one on your own in your subclass! Meaning that you have to write code to implement the functionality of one of the two desired effects.
Alternatively you can try to create an extension for one of the two library classes adding the logic from the second one. (basically the same thing)
It is highly unlikely that both subclasses would work together without any problems. As soon as both class override the same methods you are in a trouble since you have to decide which one really overrides it, etc.
I need some suggestions on how to resolve the issue I am having. I have tried several different options but hit limitation after limitation. Here is a brief overview of what is going on...
We have 40 tables that hold configuration data that needed to implement CRUD operations. We must use Telerik MVC Grid and preferably the INLINE editing. We must manage the original state and the changed properties on a single object. That object will later be serialized into the database for later approval.
Instead of making 40 models, 40 views, 120 crud methods(no delete), that will all closely share the same code except the field names. I am trying to create a way to make this generic enough where we can have 40 models (maybe?), 1 view, 3 crud methods.
I am running into limitation in various areas:
WCF doesn't support generics
Telerik grid doesn't support dynamic types
WCF doesn't keep methods and private properties intact
We are using MEF also, so this is a plugin, inside of a plugin.. i know..
Adding methods to the WCF layer is not permitted...
My Idea?
I thought I would try creating a class to hold the state, well call it ManagedState. I originally wanted the table models to inherit from it and I had it linked to track changes but this was not working.
I also have now tried using the ManagedState class separately from the configuration class
and using that strictly to pass back and forth through our WCF service. Then try using that data to create the original type and hydrate it.
Really there is so much that has gone into this I am flustered. I have no particular code to share as this is an overall question of how I would implement it as I am hitting brick walls all over. I can post code in future if I get a good response to attempt another method to implement.
I see this question had a lot of views so I figured I would respond to answer my question.
I pretty much used T4 templates to generate a TelerikGrid HTMLHelper. The Telerik grid code was generated for each type unfortunately but all I had to do was call the helper and pass my type in and it used a case statement to return the correct grid.
I am interested in general approach for building interactive GUI using MVC3.
The idea is to build set of different components that can be integrated (plugged in) into various scenarios.
Each Component MUST have it's own model definition, controller and views.
Component encapsulates not just the view but also behavior through it's controller.
All internal implementation details, model, behavior, etc... must reside inside component,
so that component becomes independent, modular - black box.
This allows component to be changed without breaking anything in context in which component is used.
Context in which component runs must not make any assumptions about internal details of component implementation.
On the other side the component does not make any assumptions about context in which it will be used.
Finally, the component must provide mechanism to "communicate" or "interact" with outside world. Beside internals, component must provide some kind of "external" interface (like parameters, data, functions, events whatever...) which would allow component to be integrated into execution context.
The Context (or scenario) is part which contains components.
Now, the basic challenge for the context is to manage interaction between components.
Real-world Categories component example:
Component displays list of categories and allows user to perform various actions such as sorting, paging and record selection.
Internally, it has it's own model which stores relevant information like current page, sort, selection, etc...
Internally, it implements all required actions (for basic render, for user actions response, etc...) in it's own controller.
Internally, it handles model state persistence in the view and model state restore in it's own controller.
Real-world Products component example:
Component displays list of products and allows user to perform various actions such as sorting, paging and record selection.
Internally, it has it's own model which stores relevant information like current page, sort, selection, etc...
Internally, it implements all required actions (for basic render, for user actions response, etc...) in it's own controller.
Internally, it handles model state persistence in the view and model state restore in it's own controller.
Real-world Dashboard page (context, scenario) example:
Page displays both Categories and Products components.
Products component displays all products for the currently selected category and thus must provide external interface (parameter or something) to receive selected category identifier from the context.
Categories component must provide some kind of external interface so that context can act when selected category changes and provide selected category identifier for the products component.
Technically, communication approach for page updates would mostly go through AJAX but if this is possible without AJAX, it would be even better.
In the case of AJAX, I would like solution which uses server side controller(s) which decides and renders what should be updated on the client (JSON or something).
I would not like solution in the client script (client side "like" controller) which decides what actions to call and what parts of page to update - this as said in previous paragraph must be decided by controller(s) on the server.
Important: It is not necessarily for the components to work when directly called via some route.
How would you generally implement described system?
I think you need to investigate real projects and see, what approach do you need to use. Try following project and u can find many best practices:
Here u can find implementing of security measures, services, auth and many many useful.
Kigg
http://www.nopcommerce.com/downloads.aspx
http://orchard.codeplex.com/
It's hard to say for me how it's should be implemented. Better to code it. But using of Dependecy Injectction of Views, Controllers, Services, and Repositories are must in your case.
Each controller handles a whole user-machine pattern. That is, roughly, each controller is responsible for orchestrating the user-machine interaction for a user-case(the user-machine patterns that are the result of the analysys phase).
Now if you put "standard behaviours" in controllers who will coordinate the user-machine interaction pattern?
This way you will have "components" without something that coordinate their execution.
In web forms you have pages that coordinates the execution of components put in them...but in Mvc thi coordination role is played by the Controllers themselves.
You can do black-boxes composed of Controllers and Views just if each of them is responsible of a whole user-machine interaction pattern. That is a "Big Components" not a small building blocks, as its is the case when you implement a CMS.
The Orchard CMS use a similar approach. However what you call components are actually pre-defined blocks that play the role of whole sections of the websites being built by the user.
It seems to me that you are trying to achieve something which may not be out-of-the-box compatible with the philosophy of web MVC (other implementations of MVC might support it).
However, if you wanted to go to the trouble of writing a framework on top of ASP MVC, I am sure you could achieve what you want. For example, by using Areas, you could achieve a form of encapsulation of your controllers, view models, and views.
To compose different areas for the same master view, you could write the equivalent of a front controller with its own view that took in a view model - that view model would be primed by the front controller to render actions from the different areas.
You might achieve more mileage by using a client framework such as Backbone.js on top of ASP MVC.
What is the best way to structure a VB.NET Windows Forms application so that code can be reused and the application can be extended easily?
I used to create lots of new forms. This lead to lots of repeated code and forms which did similar things.
Now, for forms which do similar jobs, such as view/edit/delete items from a specific database table, I create a form with the required controls, have the form create an instance of a class with parameters such as a collection of the controls and a string containing the database table name. Then the individual controls call functions of the class.
Advanced forms will inherit and extend this basic form class.
Has there already been work done in this area?
Are there books / articles available which discuss the options available on this topic?
I had great success with this Passive Screen pattern.
In my opinion, the big problem of the traditional MVC architecture is that people stuff way too much into the form classes. This increases the amount of manual testing you have to do.
The more automated testing you can do after you compile, the more bugs you will catch at your desk. In a complex application, the side effects from even minor changes occur all too often.
The trick to solving this is making a controller assembly that the form assembly (or EXE) references. Every form has a corresponding class in the assembly. Clicking a button will call ThisForm.ThisButton(<args>) which will then fire objects lower in your framework. Each form implements an interface so that, if the controller class needs additional information from the form, it has a interface to retrieve it.
Then for your unit testing you simulate an operator performing complex operations by implementing dummy classes to fire events and feed information to the controller classes. The controller classes don't know any different as the dummy classes implement all the expected interfaces.
There is an important exception and that is for trivial dialogs. For dialogs that have a few check boxes I feel this organization is overkill. I use the command pattern a lot. So in the assembly where I define the Command objects, I put the SIMPLE dialog associated with that command. How simple a dialog has to be to get this treatment is up to you.
I like to structure my applications as follows.
Utility - This is an assembly that has stuff I use all the time - Math functions, file function, etc.
Objects - This has the specific objects I am using for this application.
UIFramework - This defines all form and controller interfaces.
Commands - This has all the Command objects that manipulate my application objects.
UI - Objects that implement the controller interfaces
EXE - Forms that implement the form interface and calls the controller objects.
You may want to check out a Rocky Lhotka's popular CSLA Framework. It provides a very structured way to implement business objects so you can keep the non-UI code out of your forms. Beyond just separating your business logic though, it provides built in n-level undo, validation, security, data binding support, etc.
The one complaint most commonly directed at CSLA is that it makes test driven development difficult, so that may be something to consider as well.
Something that can help a lot is the use of User Controls. With user controls you can reuse the same UI in different forms. Also, you can have many user controls on one form, so if you have a form with a tabcontrol that has 5 tabs, the content of each tab could be a user control, so instead of having hundreds of controls all mixed up in one form, each user control has its own controls and validation logic, and you end up with just six controls in the form: the tabcontrol and the 5 user controls.
This doesn't help in separating UI code from application logic, but it enables you to have small, structured entities instead of forms with thousands of lines of code.