I'm having some strange behaviour under ASP.NET MVC3. On certain requests, I'm seeing my AllKeys collection of the QueryString having all the keys in lowercase!
The code in question is similar to the following:-
helper.ViewContext.RequestContext.HttpContext.Request.QueryString.AllKeys
Where "helper" is a System.Web.Mvc.HtmlHelper of type T of my ViewModel. This behaviour appears to be sporadic, but is causing issues as some of the downstream code in my system is expecting a case-dependant QueryString.
To try and diagnose the issue, I threw together a quick HttpModule and can confirm that on the BeginRequest event, the QueryString is NOT lowercased. So, I think something is happening within the MVC pipeline, possibly...?
Any ideas?
Thanks,
Mark
Related
In my Grails app, I am using methods in a service to do complicated validation for user submitted data. Unfortunately, Grails is quietly sabotaging me.
I populate the domain instance with the user submitted data
I hand the instance off to the service, which analyzes the properties.
If errors are found I add them using
instance.errors.rejectValue('myValue','errors.customErrorCode','Error')
BEHIND THE SCENES, when the service passes the domain instance back to the controller grails checks for changed properties and calls validate() before returning the instance. (verifiable by seeing the beforeValidate event called on returning a domain instance from a service to a controller where one or more properties has changed)
That behavior clears any custom errors I have added and the instance I get back in the controller is now incorrectly without error.
How can I
A) stop grails from validating between service and controller
OR
B) prevent a validate() call from wiping my custom errors.
EDIT
So far I've found one partial answer,
If you use instance.get(params.id), grails will self validate behind the scenes wiping custom errors.
If you use instance.read(params.id) you can bypass this behavior to an extent.docs
But this solution is limited by domain relationships. Any other solutions welcome.
Seems that it is not custom validation. It can be because of transactional service. Service opens separate transaction for each method and clears entities after method end. You can find this mentioned in docs(read the last paragraph of part ). So errors dessappear not because of validation.
Don't know if your service is transactional. But if it is - you can add #NotTransactional annotation to method were you want not to loose errors. And
errors will be saved.
Hope it helped,
Matvei.
Not sure how your code looks like or what is causing the problem, but in any case I strongly suggest implementing custom validators in the domain class or in a command object within the constrains.
Here are some examples from grails docs:
http://docs.grails.org/2.4.0/ref/Constraints/validator.html
I've seen Missing inverse property in asp.net webapi odata $metadata and the WebAPI $metadata I'm dealing with behaves as described in this article: it doesn't reuse associations for bi-directional navigation properties.
When using jaysvcutil 1.3.5 all navigational properties come up as $$unbound.
$data.Entity.extend('API.Models.Document', {
...
'Document_Versions': {
'type':'Array',
'elementType':'API.Models.Document_Versions',
'inverseProperty':'$$unbound' }
});
Other than manually updating the inverseProperty information is there anything to get the desired result automatically?
Update based on #Robesz answer
Manually adding inverseProperty information to the static .js converted by JaySvcUtil is doable, but I'm asking if there's an option to accomplish that with the dynamic conversion as well.
There seems to be to options
make modifications to the .NET WebAPI. Might be challenging, because their seem to be good reason for their implementation, but maybe somebody already successfully did that.
modifying the conversion XSLT that JayData using to take that behavior into account.
We've just arrived to the same results with WebAPI OData, but after editing the generated context file manually and adding the inverseProperty everything is working fine
This should be most probably handled by extending JayData's XSLT conversion. I've created an issues for that on https://github.com/jaydata/jaydata/issues/155.
We are currently developing a JSF 2 application and we are using OpenFaces.
One "intermittent" issue that we have been noticing is that the managed bean method "sometimes" doesn't get called.
For example:
<o:commandLink onclick="wait();" action="#{createAccountContractManagedBean.executeSave}"
execute="panGrp_createAccountContractMainTabLocal"
render="panGrp_createAccountContractLocalErrorMessages label_contractNumber pnlGrp_editCustomerGroup"
styleClass="buttonOrange"
onajaxend="wait();setTabFocus('inpHdn_contractErr','tabPane_MainLocal',3);return false;">
<span>
<h:outputLabel value="#{message['application.common.button.saveandcontinue']}"/>
</span>
</o:commandLink>
wait() is a javascript function that show a modal dialog that the request is currently in process.
setTabFocus() is a javascript function that sets the focus onto a new tab if the current save request is successful.
public void executeSave() {
if (getLoggingService().isDebugLevelEnable()) {
getLoggingService().debug(this, "executeSave");
}
// ...
}
The issue is that sometimes the managed bean method executeSave() doesn't fire at all. No log message or error.
But at the same time the onajaxend() method always fires and since there is no error, it switches the focus to the next tab.
We have tried by removing the wait(); and the setTabFocus(); methods.
All the components are in the same <h:form> element and there are no multiple forms.
What might be the possible causes when a managed bean method doesn't execute with no error trace?
May mixing JSF <h:xxx> components and <o:xxx> components in the same form cause problems?
Does mixing <o:ajax> and <f:ajax> cause problems?
Is there a possibility that on a complex form with many OpenFaces popups, that the ajax functionality might misbehave?
What might be the possible causes when a managed bean method doesn't execute with no error trace?
You could try to turn ON logging like it described here. Also you could take a look with some browser debugger tool to the ajax response from server, it probably could contain some error information.
May mixing JSF components and components in the same form cause problems?
No, in common OF have full compatibility with JSF. In some really complicated cases you could get some problems, but I don't think that the situation you've described one of them.
does mixing and cause problems?
It's normal to mix them.
Is there a possibility that on a complex form with many OpenFaces popups, that the ajax functionality might misbehave?
Of course it possible that there are some bugs in OF or even JSF, but usually you will get at list some error information in such situation. Also you could try to update to latest nightly build. Or post you problem to OF support forum.
I'm using the latest ASP.Net WebAPI Nightly builds (dated 2013-01-16).
I have a simple EF database first model at the moment that has two entities - Patients and Visits. Each patient can have many visits.
I'd like to be able to query for my list of patients and have the visits entities for each patient returned inline. I know that WebAPI's OData implementation doesn't yet support $expand. I'm hoping that just means that optional client-controlled expansion is not supported and that I can force expansion server-side.
At the moment I'm not getting any of the visits inline.
For example, my PatientController's() Get() method looks like
[Queryable(AllowedQueryOptions=AllowedQueryOptions.Supported)]
public override IQueryable<Patient> Get()
{
var query = this.entities.Patients.Include("Visits");
return query;
}
I've verified that the query executing against my database does indeed include the visit information.
To use a publicly available OData service as an example, if you use the service at http://services.odata.org/OData/OData.svc/, you can get a list of Suppliers. This is http://http://services.odata.org/OData/OData.svc/Suppliers.
You can also ask for a list of suppliers that includes the list of products using http://http://services.odata.org/OData/OData.svc/Suppliers?$expand=Products
Stepping through the ASP.NET code (via the symbols server) I've got to the System.Web.Http.OData.Formatter.Serialization.ODataEntityTypeSerializer and can see that it's CreatePropertyBag method, which builds up the list of properties to be serialized, just doesn't include the navigation properties, and they don't seem to be enumerated anywhere else apart from being written out as NavigationLinks.
I'm quite new to the ASP.NET world in general and have spent a week or so getting my head around the way things work (particularly with the changes made to OData at the end of 2012 and further changes made so far in 2013).
I suspect that if the ODataEntityTypeSerializer was to be modified (I'm happy to try) to embed this extra information in the appropriate spot (within each navigation link as an nested inline feed as best I can tell) then I'd be set.
Questions:
Have I overlooked something obvious and there's a flag I can set to turn on this behaviour? I can see why, if such a flag exists, it would be off by default (EF lazy loading and this flag wouldn't get on well)
If #1 is no, is there some other ODataEntityTypeSerializer that I could use? If so, how do I switch to it?
If #2 is no, any pointers for where I should start writing my own? Is there a place I can substitute in my own serializer or do I have to maintain my own fork of ASP.NET's Extensions project (as opposed to the Runtime project)
Thanks very much!
$expand is very high on our list of things to support for OData. But as far as I know, we don't have any flag to turn it on server-side. The formatter doesn't currently allow you to substitute your own serializers either. So I'm afraid your only option in the meantime is to create a fork and add support for $expand. If you manage to get it working, please consider sending a pull request our way:
http://aspnetwebstack.codeplex.com/SourceControl/network
You can try it already in webapi nightly builds.
Here is how to install it with nuget:
http://aspnetwebstack.codeplex.com/wikipage?title=Use%20Nightly%20Builds
I'd like to be able to access some HTTP GET parameters directly in a JSP, without having to pass them through a Controller+Model, but at the same time still use the dispatcher/controller/model/view mechanism for other parameters and logic.
This is because I have many HTTP GET parameters that are generated by Javascript and used also only in Javascript. My Controllers don't need them at all.
I tried ${arg}, ${request.arg}, ${requestScope.arg}, nothing seems to work.
If I bypass the dispatcher, ${requestScope.arg} works.
But is there a way to make it work with the dispatcher?
Thanks!
If that's request parameters that you want to access (and not request attributes like the title says), then the syntax is ${param.parameterName}.
If it's request attributes, then it's ${requestScope.attributeName}.
See http://java.sun.com/products/jsp/syntax/2.0/syntaxref207.html#1010522 for a quick reference.