i put all my custom "update" code in the RowCommand event, it works fine, but i still get an error from my Data Source
System.NotSupportedException: Updating
is not supported by ObjectDataSource
'GetSources' unless the UpdateMethod
is specified.
how can i get rid of that error , yes still use my custom update code on the rowcommand?
Well, I think the way the ObjectDataSource is intended to be used is you specify the name of the method in your custom business object, and it will use reflection to call that method.
So, your page and object might look something like this:
<asp:objectdatasource
id="ObjectDataSource2"
runat="server"
updatemethod="MyUpdateMethod"
typename="MyBusinessObject">
<updateparameters>
<asp:controlparameter name="anID" controlid="DropDownList1" propertyname="SelectedValue" />
</updateparameters>
</asp:objectdatasource>
Public Class MyBusinessObject
Public Shared Sub MyUpdateMethod(anID As String)
'data access code
End Sub
End Class
This pattern of putting control together can be quite productive, but you'll probably feel too restricted after a while.
Related
I was making a method call objectMapper.writeValueAsString in EL like this.
<%# attribute name="actionItems" required="true" rtexprvalue="true" type="java.util.List"%>
<jsp:useBean id="objectMapper" class="org.codehaus.jackson.map.ObjectMapper" scope="page" />
<jsp:useBean id="actionItemsMap" class="java.util.HashMap" />
<c:set target="${actionItemsMap}" property="actionItems" value="${objectMapper.writeValueAsString(actionItems)}" />
writeValueAsString takes an Object parameter in method signature. It was working when I pass in actionItems which is an ArrayList.
Now I am upgrading my ApacheTomcat 7 from 7.0.52 to 7.0.70, and the code is broken with MethodNotFoundException:
javax.el.MethodNotFoundException: java.lang.NoSuchMethodException: org.codehaus.jackson.map.ObjectMapper.writeValueAsString(java.util.ArrayList)
at javax.el.BeanELResolver.invoke(BeanELResolver.java:422)
at org.apache.jasper.el.JasperELResolver.invoke(JasperELResolver.java:139)
It is trying to find a method writeValueAsString with argument type ArrayList. It seems related to this change in 7.0.53. How should I change my code to make it work? Do I have to make the method call with an Object argument? If so, is there a way I can cast the ArrayList to an Object in EL and then make the method call?
Turns out this is an issue on our side. These parameterized method calls are supported.
On any change to a dbml via the graphical interface (add a table/stored proc) every reference to System.Int32 gets changed to System.[Integer] (square brackets included) causing hundreds of errors.
This is manifest everywhere in this dbml designer.vb such as:
Public Property ArghID() As System.[Integer]
Public Function PleaseHelpDetails(.... <Global.System.Data.Linq.Mapping.ParameterAttribute(Name:="WhyWhyWhyID", DbType:="Int")> ByVal WhyWhyWhyID As System.[Integer], ...
Private _AnnoyanceID As System.[Integer]
Partial Private Sub OnHauntedDbmlIDChanging(value As System.[Integer])
I can find no references to this. Can anyone speculate as to the cause?
A search and replace fixes this, but it is a complete nuisance.
Update: Having Tried the classic "delete the appropriate "*AppData\Local\Temp\Temporary ASP.NET Files* folders" trick - with no luck.
Took a look at the SVN history of the file - and some IDs were set up as bytes(!) - and those were changed to integers at some point, manually. I am looking for some inconsistency with this - but can't find anything yet.
So there it is - search and replace had search and destroyed the dbml.
The definition of the table columns were set up like this in the dbml file:
<Column Name="WellObviouslyID" Type="System.Integer" DbType="Int NOT NULL" CanBeNull="false" />
instead of
<Column Name="WellObviouslyID" Type="System.Int32" DbType="Int NOT NULL" CanBeNull="false" />
and forced their integrity on the other occurrences in the .designer page.
It was a poor choice in replacing strings that led to this. As ever, avoidable by doing things via the gui. Trying to save time is always perilous.
I have an ODS, which is bound to an ADO.NET datatable. There is one select parameter. I would like to use a public property which I have declared in my code-behind as the select parameter, something like:
<SelectParameters>
<asp:ControlParameter ControlID='<%# EInfoProperty %>' Name="quote_header_id"
PropertyName="headerId" Type="Int32" />
</SelectParameters>
The above syntax doesn't work, and I've been unable to find anything here, on MSDN or on Google that might help here. Is there a way to do this, or am I stuck sticking the value in the Session, or something?
From everything I could find, this is not currently possible. For my purposes, I ended up putting the value in question in the session and using a SessionParameter.
I want to set a property in a custom action and use it in the standard custom action "util:User" afterwards. But no matter where I put the property in my wxs-file, I always get "error LGHT0094 : Unresolved reference to symbol"
Details:
In my setup I want to add a new user by using util:User. The user should be added to the group "Power Users" by using util:GroupRef. No Problem so far. Unfortunately the group names are language dependent. In german "Power Users" is "Hauptbenutzer". So I want to look up the well known SID S-1-5-32-547 in a custom action, set a property in this custom action by calling MsiSetProperty and then use the property for util:GroupRef.
As far as I understand, the property must be declared somewhere in the wxs-file.
In the examples I found, the property was never declared as follows (but I also tried that):
<Property Id="TextSID" Value="Power Users" />
In the examples there always was a custom action to set the property, like:
<CustomAction Id="SetTextSID"
Property="TextSID"
Value="Power Users"
Return="check" />
My problem is, that the creation of the user fails to "compile" because the property "TextSID" is not known:
<Component Id="CreateUser" Guid="Some GUID here in my original wxs file">
<util:User Id="UserUser"
Name="User" Password="Password"
CanNotChangePassword="yes" PasswordNeverExpires="yes">
<util:GroupRef Id="TextSID" />
</util:User>
</Component>
I have never done a custom action before and I'm a new to WiX and MSI, so any idea would be very welcome.
Regards
Ralf
Sorry for wasting your time.
I stared at my XML for hours before I posted this question, just to find the answer immediately after my post :-(
My only problem was, that it is not possible to reference to something that isn't there. In this case the "util:Group" was missing.
I'm designing some VB based ASP.NET 2.0, and I am trying to make more use of the various ASP tags that visual studio provides, rather than hand writing everything in the code-behind. I want to pass in an outside variable from the Session to identify who the user is for the query.
<asp:sqldatasource id="DataStores" runat="server" connectionstring="<%$ ConnectionStrings:MY_CONNECTION %>"
providername="<%$ ConnectionStrings:MY_CONNECTION.ProviderName %>"
selectcommand="SELECT THING1, THING2 FROM DATA_TABLE WHERE (THING2 IN (SELECT THING2 FROM RELATED_DATA_TABLE WHERE (USERNAME = #user)))"
onselecting="Data_Stores_Selecting">
<SelectParameters>
<asp:parameter name="user" defaultvalue ="" />
</SelectParameters>
</asp:sqldatasource>
And on my code behind I have:
Protected Sub Data_Stores_Selecting(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.SqlDataSourceSelectingEventArgs) Handles Data_Stores.Selecting
e.Command.Parameters("user").Value = Session("userid")
End Sub
Oracle squaks at me with ORA-01036, illegal variable name. Am I declaring the variable wrong in the query?
I thought external variables share the same name with a # prefixed. from what I understand, this should be placing the value I want into the query when it executes the select.
EDIT: Okay, thanks for the advice so far, first error was corrected, I need to use : and not # for the variable declaration in the query. Now it generates an ORA-01745 invalid host/bind variable name.
EDIT AGAIN: Okay, looks like user was a reserved word. It works now! Thanks for other points of view on this one. I hadn't thought of that approach.
I believe Oracle uses the colon ":", not the at-symbol "#".
"user" is probably a reserved word. Change it to "userID", or something similar.
You may want to consider using a SessionParameter instead of just a Parameter and let the SqlDataSource extract the user id directly from the session without any intervention on your part. Also, the example on the page linked above seems to imply that you should use ? instead of #user for parameter replacement for an ODBC connection. I think the parameter replacement would be done by the SqlDataSource and not passed to Oracle, that is it would substitute the actual value of the user id in place of the parameter (properly quoted of course) before sending the query to the database.
<SelectParameters>
<SessionParameter Name="userID" SessionField="user" DefaultValue="" />
</SelectParameters>
Using ASP.NET's SessionParameter is definitely the way to go here - that's why we have it :)
Using ASP.NET parameters you can easily include in your queries values from static sources, session state, query string, control property values, form post data, cookies, and user profile.
<asp:sqldatasource id="DataStores" runat="server" connectionstring="<%$ ConnectionStrings:MY_CONNECTION %>"
providername="<%$ ConnectionStrings:MY_CONNECTION.ProviderName %>"
selectcommand="SELECT THING1, THING2 FROM DATA_TABLE WHERE (THING2 IN (SELECT THING2 FROM RELATED_DATA_TABLE WHERE (USERNAME = #user)))"
onselecting="NAME_OF_SUB_Selecting">
<SelectParameters>
<asp:parameter name="#user1" defaultvalue ="" />
</SelectParameters>
</asp:sqldatasource>
Protected Sub NAME_OF_SUB_Selecting(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.SqlDataSourceSelectingEventArgs) Handles Data_Stores.Selecting
e.Command.Parameters("#user1").Value = Membership.GetUser.ProviderUserKey.ToString()
End Sub