What does Database.AddInParameter() method do? - asp.net-mvc

I was debugging datahandler for an mvc4 application, and I came across the
AddInParameter(DbCommand, String, DbType);
and I looked for the same in MSDN, but there its mentioned as retired content and there is not much documentation. So please anybody help me to understand what it does?

1st Parameter, DbCommand - is the command you want to execute on your database, e.g. StoredProc, SqlString etc.
2nd Parameter, Parameter Name - is the name of your parameter
3rd DbType, DbType - is the type of your parameter e.g. String
Basically this will add an Input parameter which can be used in your DbCommand. The AddInParmeter method works similarly like the SqlCommand.Parameters.Add() of the System.Data.SqlClient namespace.

Related

Include multiple parameters inside SAML RelayState parameter

Basically have an issue when I set the RelayState parameter to /test/example?key=value&key1=value1 , key1=value1 is being split away from the RelayState parameter instead of being included in it like "/test/example?key=value&key1=value1". I would be grateful for any assistance. Thanks
I resolved this myself, basically when you build the page reference in apex code, you should only use the base url in the constructor, no parameters. Then, you add the parameters to the Page Reference's parameter map variable. That way the parameter is not split. Thanks!

Is it OK invoke a methode in el expression but not for a action?

recently, I get some code like rendered="#{bean.show()}". and it works. since jsf 2, we can do things like this, even in the js, like if("#{bean.show()}) alert('I am here!');
I want to know, what is the difference call a method or use a getter? Is there a performance issue?
thanks in advance
Liu
Call method it means what you do action and handle response: do navigation for example.
Every field should have getter and setter for get data and set data from web page. If you have field for example
private String username;
you should have also getter and setter, and get/set value with that method according java requirements,you cant have
public String username
//never do this
and access field directly.
also getter/setter does not connect with performance, till your code is correct.
You should review java core part and also JSF tutorial
JSF tutorial

XOM Parser Element.getAttributeValue() returns null if attribute name has :

I have been using XOM parser in a project that is mostly over. The parser is very good and I find it mostly stable. However today I was parsing an XML element with an attribute called "xml:lang"
The getAttributeValue("xml:lang") returned null instead of "English". I could find a work around to get the value by using getAttribute(int location).getValue()
However, it would be better to use the method getAttributeValue because the attribute's location changes for other elements.
I am not sure whether I am doing something wrong or a small bug lies there in the library method.
The xml:lang attribute is in a namespace.
To get the value of an attribute in a namespace, use the Element.getAttributeValue(String, String) method. The first parameter needs to be the local name of the attribute (after the colon), which is lang in this case. The second parameter needs to be the URI of the namespace, which is usually defined in an ancestor element. The xml namespace, however, is built in and always has the namespace URI http://www.w3.org/XML/1998/namespace.
Therefore, some code like this should do what you want (assuming you have a variable called element pointing to your element):
String lang = element.getAttributeValue("lang", "http://www.w3.org/XML/1998/namespace");

T4MVC: What are MVC.Controller.ActionParams are for?

I've found properties corresponding to each action named like this: MVC.<Controller>.<Action>Params, they contain parameter names for each action. What are they for and how they can be used?
There were some edge scenarios where it was interesting to pass the parameter name as a constant. I can't instantly recall what that person was doing, but I could see this being useful is calls to AddRouteValue. In the end, it's all about never to have to use a literal string that refers to a C# object, whether it's a class, method, or param.

Please help me with ASP.NET MVC Paging error

I am getting the following error in my mvc application when I am doing the paging functionality
CS1061: 'System.Collections.Generic.IEnumerable' does not contain a definition for 'HasPreviousPage' and no extension method 'HasPreviousPage' accepting a first argument of type 'System.Collections.Generic.IEnumerable' could be found (are you missing a using directive or an assembly reference?)
please tell me what to do and what is that Model.
This reminds me of the PaginatedList<T> class found in the Conery et al MVC 1.0 Wrox book... (And probably also found in the NerdDinner app.) I actually have this book right here next to me and have this section tabbed. And sure enough they have a property called HasPreviousPage, which leads me to guess this is what you are working with? It is in Chapter 1, which is a free download. (Google for it.) I highly recommend taking a look at this chapter, or at least this section, as there are many other helpful suggestions and tips to be found!
Best of luck!
I think that you may be missing a namespace import.
Is HasPreviousPage a method or a property? If it is a helpermethod on the type of list you are returning then you need to import that namespace in your aspx file (or in the web.config to reflect on all pages)
You need to change the controller to use Paging, check out http://blogs.embarcadero.com/johnk/2009/04/02/38871 for more info
EDIT: To clarify, so somewhere in the Controller, you're gonna see something to the effect of "return View(someModelObject)" - you need to use PaginationHelper.AsPagination here to turn someModelObject into a pageable object
There are a few possibilities here:
First off, Model is your object, or class. HasPreviousPage is a method or function in Model.
Here are some possibilities:
Model is not defined because the file is not included in the page
HasPreviousPage does not exist as a method
HasPreviousPage is actually a property and needs more information to extract data (as tster is saying)
The signature for HasPreviousPage is incorrect. You are sending too much, or not enough data.
My guess is it's either a boolean property, or a method that returns a boolean. Either way the compiler has no idea what to do with it, so you need to track it down. Try doing a find in your solution for "HasPreviousPage". See if it's been referenced anywhere, or where it is located.
Ctrl + F
Find What:
HasPreviousPage
Look In:
Entire Solution

Resources