Starting controller for Rhomobile ? - rhomobile

What is the starting point for my Rhodes mobile application , the way I understand it , that Rhodes is an MVC based framework, let's assume that when I start the application, I will need to make some validation before deciding which is the appropriate view to show, like as for example if the user is an admin then I will need to show admin view .
I can't find the main controller to do such a thing, all what I can see is index.erb, but what I'm trying to find is the main controller to decide if i'm going to use index.erb or any other view .
I'm sure there must be work around to do that, please note that i'm very new to Rhomobile .

Please check how to use the rhoconfig.txt so that you can set what Controller you would like to call when app start.
http://docs.rhomobile.com/rhodes/configuration#run-time-configuration
You can then write your own logic for handling users.
You can also point to app/Settings/login so that you can handle the logic in do_login method

Related

Multirole iOS application - Should Logic in Same or Different View Controllers for Multiple Roles?

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.

How do I make an MVC Billing page?

I've made a music store using the tutorials on ASP.net and they do not show you how to make a billing page. What I would like to know is would I have to make a new controller and view for it or will I just need a view and to add a piece of code to an existing controller? Also, how can I make the page so that it authorizes the details given, for example, will know when the card details are not correct like the wrong security code or wrong card number in general?
Much appreciated
So you need to continue to tutorials on asp.net mvc site you should try the tutorial on models page code first with entity framework there are so many samples about validation.
For the credicard validation there is an algorythym of this named Luhn Formula, so really you don't have to know how to validate, there is a asp.net code that has been written and works on the link also you can use javascript validators on view to give better service.
http://www.codeproject.com/KB/aspnet/wdxcreditcardvalidation.aspx
you just need to write a code on controller (it just to show you how it's done, you may need to write additional codes)
if(luhnisvalid(Order.billingdetails.CreditCard))
{
// then adding to database
}
or return to view
return(View(Order));
and finally continue to this tutorial it will give you so much information, after the tutorial i'm sure that you can make the billing part.
http://www.asp.net/entity-framework/tutorials/creating-an-entity-framework-data-model-for-an-asp-net-mvc-application

asp.net mvc Controller - View logic

I'm trying to learn the asp.net mvc. I have worked with most of the samples that MS have published.
Most of the samples is just about CRUD.
I'm pretty good at working with webforms, but now I kind of miss the old easy world.
But, my question is: I have a detail page that is connected to an order, I have the order details comming along all well. I got my order detail lines kind of work. But now I would like to do different things with this order, like add more order lines, change the order status with a button, email the order and so on. In webforms I just added eventhandlers on the click event, but here... Do I need multiple forms? How do I make serverside code for example when someone wants to change the orderstatus with a click of a button?
Hi i can recomend you Pro ASP.NET MVC 2 Framework book by Steven Sanderson
I'd recommend you go through the entire NerdDinner tutorial.
But to answer your question:
There really are no forms in asp.net MVC. There are views, which show your order, and there are controllers/actions which allow you to run code to generate views, update your database, etc. You ask if you need another form - the answer is No. You will, however, need at least a new action on a controller, and possibly a new view to confirm that the order was changed. An overview to a very simplified solution would be:
You want to allow an order to be marked as closed by clicking a button. Assume you have a controller called Order, and a view (in the order views folder) called Details. You'll have to add an action which takes an integer as a parameter to your order controller called "Close". In that action, you'll read the integer parameter (the order ID) and execute code to update that particular order to closed. You'll probably want to return the same view with the udpated status from this action. You'll have to add a link (probably using HTML.ActionLink function) to your view to call this new action.
In MVC everything is Post and Get actions. You can post to difference controllers. It seems you need to spent a bit more time reading about it. If you do not fancy reading - try some nice video tutorials for beginners. http://www.asp.net/mvc

Grails: reusing an action

I'm building an application that among other things allows users to upload documents. I have the basic create/view actions working just fine, but i'd like to reuse this action in other places.
I want to know if anyone has a pointer for how to do this. There doesn't seem to be a very good way of doing this.
Here are a few ways i've considered:
Try to do a chain(). This doesn't work since chaining does a GET, and to upload you need a POST.
Break out the main business logic into the Grails "service", and make two actions that use the same code.
Use a JS modal window. I've been thinking a modal that contains an iframe to an "unskinned" version of the document upload. The trick here is to get the window to close when the upload is done.
Thanks
--Matthias
I don't care for the extending controller method. In fact, I avoid inheritance when possible. I'd rather put the common code in a service class and reuse it that way.
You can use a base controller class, and place the common functionality there. Then extend the base controller and call the method from other action methods.

How to name Asp.net Mvc controllers?

I am kinda of confused on when I should be making a new controller it seems like every time I make a button that goes somewhere I would need to make a new controller to get the right pathing names.
For instance in this scenario I have a signIn controller.
this controller would have
1. Login view
2. RestPassword view
3. CreateAccount view
So if they click login they go to some other controller(lets call it AccountController) so this will have all the account view and stuff in it.
Now how about the RestPassword view? When it rests the user password I want it to go to a page that shows them that it was a success(most sites seem to do this for example asp.net site if you enter in a email address it will go to another page and tell you that the new password has been sent).
So now what should it be another view? a controller?
If it is a view then the pathing would look like
http://www.site.com/signIn/EmailForgottenPassword
what kind of looks weird to me.
If I make a new controller then I could have
http://www.site.com/EmailForgottenPassword
What looks alot better to me but this controller would have one just one view in it.
Another example would be on this sigIn page their is a Create Account button. Now when clicked this goes to another page that has a list of different accounts.
Should this also be a new controller? When the accounts are listed on this new page they all link to a Registration Controller with many views in it.
so it would be like SignController -> RegistrationController -> RegistrationController.
this would probably get some nice links.
So like I said it seems like to get nice links that make sense you need to constantly make new controller after controller.
So I must be missing something.
The truth is you never actually need more than one controller. Separate controllers are just ways of separating your concerns. In other words, OO design paradigms impel us to logically divide our code into modules, but you don't have to - everything can be in one controller.
What you do need is a separate controller action for each different type of request you want to process. That is, you need a controller method exposed to the routing table that can be called by typing in some URL and/or providing some GET or POST data. This method then decides what to show the user (the view).
Also, you can have any URL you want point to any controller or controller action you want by modifying the routing table in Globals.asax.
You probably have more specific questions about my answer - please post them and I will edit them in.
In your specific case you one controller would suffice. I would name it the AccountController and add the following actions to it.
Login
Logout
Create
CreateConfirmation
ResetPassword
ResetPasswordConfirmation
then for the ones you want to have confirmation screens you can use the the Post Redirect Get (PRG) pattern.
as to the naming. In general you want to use noun for a controller and verbs for actions on those controllers. That way you get nice readable URL's that make sense. And for the noun you can pick the logical/business term (better then the technical term) that the controller deals with. So accounts, customers, products, blogpost etc...
If you are following SOLID principles then you should name them very specifically. If you are using ASP.NET MVC 2 then I would put major widgets into "areas" and then give controllers good names. Make your URLs happy!

Resources