I am trying to use TimeSpan as a parameter type for an action in a controller, but the value is always now, so I presume it is not parsed correctly by MVC. The value that gets sent to it is "7:00 PM". Is it possible to make MVC support such format? I am using MVC 2.
Firstly, why doesn't Dictionary<TKey, TValue> support a single null key?
Secondly, is there an existing dictionary-like collection that does?
I want to store an "empty" or "missing" or "default" System.Type, thought null would work well for this.
More specifically, I've written this class:
class Switch
{
private Dictionary<Type, Action<object>> _dict;
public Switch(params KeyValuePair<Type, Action<object>>[] cases)
{
_dict = new Dictionary<Type, Action<object>>(cases.Length);
foreach (var entry in cases)
_dict.Add(entry.Key, entry.Value);
}
public void Execute(object obj)
{
var type = obj.GetType();
if (_dict.ContainsKey(type))
_dict[type](obj);
}
public static void Execute(object obj, params KeyValuePair<Type, Action<object>>[] cases)
{
var type = obj.GetType();
foreach (var entry in cases)
{
if (entry.Key == null || type.IsAssignableFrom(entry.Key))
{
entry.Value(obj);
break;
}
}
}
public static KeyValuePair<Type, Action<object>> Case<T>(Action action)
{
return new KeyValuePair<Type, Action<object>>(typeof(T), x => action());
}
public static KeyValuePair<Type, Action<object>> Case<T>(Action<T> action)
{
return new KeyValuePair<Type, Action<object>>(typeof(T), x => action((T)x));
}
public static KeyValuePair<Type, Action<object>> Default(Action action)
{
return new KeyValuePair<Type, Action<object>>(null, x => action());
}
}
For switching on types. There are two ways to use it:
Statically. Just call Switch.Execute(yourObject, Switch.Case<YourType>(x => x.Action()))
Precompiled. Create a switch, and then use it later with switchInstance.Execute(yourObject)
Works great except when you try to add a default case to the "precompiled" version (null argument exception).
hello,
I would create a view programitically , then Can i place the navigation controller upon a view by making the view as rootview? and then return the rootview to the window object in Objective-C for iPhone programming.
Is this possible?
Hi,
I am a newbie to Zend framework, I want to know how can we restrict the call to predispatch() function in my controller for any particular action.
-DevD
I have made a navigation based application in my rootview controller i have put a text view when i run the app i am able to see that text view but when i navigate on other xib and comes back i am not able to see that text view if i do it programmatically by using view for header than i am able to c that text but why i am not able to do it in design time
any idea
Within my site I have controller specific CSS files in addition to my master css file. For example
CSS/
Prodcuts/
product.css
...
Blog/
blog.css
...
masterStyle.css
Where masterStyle.css is the master css file. What I want to do is when the user hits http://www.example.com/Products/ only mySite.css and all css files under Products get included. What is the best way to go about doing this?
Could I somehow disable action (send, redirect) from submit if the textarea was empty (so nothing at all happens onclick). I want to avoid displaying error here, thats why I'm asking.
My textarea:
<textarea id="message" name="message" maxlength="35"></textarea>
My submit button:
<input id="send" type="image" src="/site_media/static/images/submit.png" value="Submit">
This is what i tried: http://jsfiddle.net/5Xwyb/
My brain died couple of hours ago.
Hello,
I am using rails 3:
I would like to render a portion of view which is build by a 'notification' method in message class
so I've add in my application.html.erb :
<li><%= render :action => "notification", :controller => "messages" %></li>
The goal of my file notification.html.erb is to display in a red circle the number of notifications in all my pages.
I don't think I am in the good way, any ideas ?
Thanks all :)
i m suffering with Passing values from javascript function to controller in cakephp and get using $_POST.
i have tried it by different ways but didn't get success please suggest........
hi.
I have a multiple file upload form(html5) and want to update my view as soon one of the images is transfered to my image server.
Currently I upload the files with ajax and use response_to_parent to update my upload view when all images are transfered to the image server.
Is it possible to call a Javascript function from the controller more than once per action?
def upload
params[:images].each do |file|
upload_to_image_server(file)
#page << Update upload View
end
end
Thanks,
Michael
I want to add simple list/combo box with action script 3 . but i have not found anything in internet.
Can anyone give me sough rough idea with some dummy values
thanks
I there a way how to take photos on laptop built-in camera controlling its control using flash? Our designer is making an application to take photos using flash action script or anything PL if not possible in flash.
Hi
In my mode I am selecting a field as
$query1 = $this->db->query("SELECT dPassword
FROM tbl_login
WHERE dEmailID='[email protected]'");
How to return dpassword as a variable to my controller
I tried this way return dpassword;
I have a view that only has a button UIButton. First time clicking the button will draw a square above the button and the second time will replace the square with a circle.
I need some help on writing the controller code. Please guide me to the right path. Thanks
How can I make DialogBox (confirmation message and OK & Cancel buttons) wait for user action and return boolean result (true is OK was clicked, false otherwise)?
Thanks in advance.
I writing a Struts 2 application. The main operation I'm trying now is to read from the action call a List and display it in the form of a table in the JSP.
I've searched the net and check out a lot of examples, but in vain.
Can someone point out to a good working example?
I'm trying to install Image Magick on MAMP. And I'm seriously out of my depth.
I've installed MacPorts, and opened the terminal. I've typed in sudo port -v selfupdate per the instructions on http://www.macports.org/install.php#pkg
But the response I get from the Terminal is Unrecognized action "sudo"
I've googled and googled, but can't find anything that makes a slab of sense.
Any clever people feeling generous?
Hi,
why should i use a component instead of an action that renders a partial?
If actions can render partials, when is better using components?
Give me light about it..
Javi
Hi I'm using struts 2.
I'm trying to reload a target div from a javascript by using jquery to target the div and a struts action that loads the content.
Does anyone know how to do this?
The problem is how I use (javascript) jquery to do this.
BR, Tobias
Hello there - I create a new project using splitview template (iPad).
So far so good. What I am trying to accomplish now it have my own view (which in a NIB) in popupview controller.
By default the template provides the table which I don't want to use.
How can I do that?
In my app I've been using the now deprecated shouldAutoRotateToFace method. Now when using the iOS 6 simulator, all of my subviews are rotated to portrait orientation while the device is in landscape. Does anyone have any idea what could cause this? I've already tried replacing should autorotate in my main view controller with the supportedOrientations method (or whatever it is that you're now supposed to use instead).
I have an Java class, like Library, that contains many fields. I want do ajax call to server
and in controller's method I want to have partly initialized @RequestBody Library with only
fields, which are present in json object.
Please Help