Manually adding text to html.ValidationSummary? - visual-studio-2010

I am rather new to mvc2 and when following a writeup on data annotations and such, I came across a bit of code that let me manually add a line of text to the validation summary.
I've searched for the last 2 or 3 hours and I've come to the point where I think I'm just searching for the wrong thing. Its not custom validators I'm looking for, but something that I can call from the controller to add error messages.
Does anyone know what I'm talking about?
edit: clarified title a bit

Are you looking for:
ModelState.AddModelError("*", "There was an error processing your request")
MSDN - ModelStateDictionary.AddModelError Method (String, String)
MSDN - Validating Model Data in an MVC Application
HTHs,
Charles

Related

Using Pinterest Marketing api to fetch all entities?

Is there an edge that would allow fetching all the campaigns, adgroups, etc., of a given advertiser? In researching this I see these:
GET /ads/v3/campaigns/{campaign}/
GET /ads/v3/adgroups/{adgroup}/
...
which return only single entities. I also found that there is an async report that returns entities in batch:
advertisers/<advertiser ID>/entities/batch/
Is this the best way to accomplish this? If so, the doc says it only supports campaigns right now, is that still the case?
Thanks
Sorry to waste your time folks, I've since found more and better doc and discovered that there is this:
/ads/v3/advertisers/{advertiser}/campaigns/
Here is a link to the doc for your own reference:
https://developers.pinterest.com/docs/redoc/#operation/ads_v3_get_advertiser_campaigns_handler_GET

Which fields does -[NSResponder presentError:] show?

Is there any documentation about how the -[NSResponder presentError:] method works? I'm trying to create NSError instances in my library whose userInfo values show as much useful information to the user as possible. I'm having a tough time.
I started out using just NSLocalizedFailureReasonErrorKey. Seeing that it assigned the messageText property of the generated NSAlert (bold font, topmost label), I next tried adding on NSLocalizedDescriptionKey, which I thought would then fill in the informativeText property, for a non-bold explanation under it. I also added NSURLErrorKey, since this library deals with files and it would be helpful.
The resulting NSAlert doesn't show the original NSLocalizedFailureReasonErrorKey value at all, with the new NSLocalizedDescriptionKey now becoming the messageText. It also doesn't expose the NSURLErrorKey at all, either.
Is my only option to write my own error presentation method and special-case this library's domain?
How the NSError keys interact with presentError: is documented in the Error Handling Programming Guide under Localized Error Information.
It includes a diagram detailing what goes where. As the docs note:
Failure reason
A brief sentence that explains the reason why the error occurred. It is typically part of the error description. Methods such as presentError: do not automatically display the failure reason because it is already included in the error description. The failure reason is for clients that only want to display the reason for the failure.
If you want to rearrange the fields in an NSError object prior to presentation, this is best done by overriding willPresentError: to return an adjusted error object.
Regarding fields like NSURLErrorKey, it is expected that you will have included this in NSLocalizedDescriptionKey or NSLocalizedRecoverySuggestionErrorKey if you want to display it. While it is called the "recovery suggestion," the documentation is explicit that it may be used "as a purely informative message supplementing the error description and failure reason."

Ruby viewpoint with EWS

I am trying to get started using viewpoint against EWS within Ruby, and it's not making a lot of sense at the moment. I am wondering where I can get some good example code, or some pointers? I am using 1.0.0-beta.
For example: I know the name of the calendar folder I want to use, so I could search for it, but how to access methods in that folder once I find it? What are the appropriate parameters, etc...
Any advice?
If you haven't read it yet I would recommend the README file in the repository. It has a couple of examples that should put you on the right path. Also, the generated API documentation should give you enough to work with.
http://rubydoc.info/github/WinRb/Viewpoint/frames
At a very basic level you can get all of your calendar events with the following code:
calendar = client.get_folder :calendar
events = calendar.items
I hope that gives you a little more to get started with.
Follow-up:
Again, I would point you to the API docs for concrete methods like #items. There are however dynamically added methods depending on the type that you can fetch with obj.ews_methods. In the case of CalendarItem one of those methods is #name so you can call obj.name to get the folder name. The dynamic methods are all backed by a formatted Hash based on the returned SOAP packet. You can see it in its raw format by issuing obj.ews_item
Cheers,
Dan

Adding an extension to the blog post pages on liferay

My problem is i want to add '.html' extension to my every blog post. For example right now i have a blog post url 'http://www.indu.com/blog/-/blogs/creating-a-custom-portlet-in-liferay' and what i want is 'http://www.indu.com/blog/-/blogs/creating-a-custom-portlet-in-liferay.html'
I would be grateful if any one can help?
I wonder why would you want this.
Anyways, I think you can change the urlTitle field of BlogsEntry and append .html to the string. May be use a service-wrapper-hook to append .html to the urlTitle whenever a blog is created or updated.
Or you can even use a ModelListener if it exists for BlogsEntry hook to update the blog's urlTitle by using onCreate & onUpdate methods.
Edit
The urlTitle field is present in the BlogsEntry table.
You can access this in java with the following methods:
BlogsEntry blog = BlogsEntryLocalServiceUtil.getBlogsEntry(90989); // retrieves the blog-entry
String blogUrlTitle = blog.getUrlTitle();
blog.setUrlTitle(blogUrlTitle + ".html"); // this would set the string
You can have a check for the blogUrlTitle so that you don't have repeated .html appended to the string:
if (!blogUrlTitle.contains(".html")) { // append only if the title does not contain `.html`
blog.setUrlTitle(blogUrlTitle + ".html");
}
You can refine your code as you like, the above is just a guide-line.
As a side-note, I would always try to reason with the client why they want something, this helps not only to fend-off bad-change-requests but also helps in giving an alternative to the client (which is less taxing on the developers like us ;-) ). In most cases this helps to understand the client's business better & provide better returns.

Sorting a view by dropdown

Hey, i've been looking around for a ajax dropdown sorter for my Views in Drupal.
Unfortunatly, i haven't found alot of usefull information about this subject.
Can anyone tell me if theres a solution already available or can help me started on a custom module by telling me which hooks i should use?
I had a similar issue. Unfortunately I wasn't able to sort the data from the database which is by far the best way. I was however able to take the data and sort it with PHP using a preprocessor function. Depending on the name of your view, setup a function similar to the following:
function templatename_preprocess_name_of__view(&$vars)
{
//Super sweet sorting code goes here
}
The name of your view needs to follow the name of the template file that it is driven by, if there isn't on you should create one. Make sure to change dashes to underscores in your function name. Hope this is helpful. If you find a way to do it from the DB I'm all ears because that would be super awesome.

Resources