I have heard conflicting stories on this topic and am looking for a little bit of clarity.
How would one dispose of a string object immediately, or at the very least clear traces of it?
Hi,
I'm a bit of a jQuery n00b so please excuse me if this seems like a stupid question. I am creating a site using the jQuery UI more specifically the sortable portlets. I have been able store whether or not a portlet is has been open or closed to a cookie. This is done using the following code. The slider ID is currently where the controls are stored to turn each portlet on and off.
var cookie = $.cookie("hidden");
var hidden = cookie ? cookie.split("|").getUnique() : [];
var cookieExpires = 7; // cookie expires in 7 days, or set this as a date object to specify a date
// Remember content that was hidden
$.each( hidden, function(){
var pid = this; //parseInt(this,10);
$('#' + pid).hide();
$("#slider div[name='" + pid + "']").addClass('add');
})
// Add Click functionality
$("#slider div").click(function(){
$(this).toggleClass('add');
var el = $("div#" + $(this).attr('name'));
el.toggle();
updateCookie(el);
});
$('a.toggle').click(function(){
$(this).parents(".portlet").hide();
// *** Below line just needs to select the correct 'id' and insert as selector i.e ('#slider div#block-1') and then update cookie! ***
$('#slider div').addClass('add');
});
// Update the Cookie
function updateCookie(el){
var indx = el.attr('id');
var tmp = hidden.getUnique();
if (el.is(':hidden')) {
// add index of widget to hidden list
tmp.push(indx);
} else {
// remove element id from the list
tmp.splice( tmp.indexOf(indx) , 1);
}
hidden = tmp.getUnique();
$.cookie("hidden", hidden.join('|'), { expires: cookieExpires } );
}
})
// Return a unique array.
Array.prototype.getUnique = function() {
var o = new Object();
var i, e;
for (i = 0; e = this[i]; i++) {o[e] = 1};
var a = new Array();
for (e in o) {a.push (e)};
return a;
}
What I would like to do is also add a [x] into the corner of each portlet to give the user another way of hiding it but I'm unable to currently get this to store within the Cookie using the code above.
Can anyone give me a pointer of how I would do this?
Thanks in advance!
Gareth
hi,
I am trying to make asynchronous calls using xmlhttprequest object
so it completely works fine in internet explorer but for firefox it wont work
a small code snippet of problem
if (req.readyState == 4) {
if (req.status == 200) //here firefox gives status code always 0 and for IE works fine
{
//read response
} else {
alert("There was a problem with the request.");
}
}
I was unable to find any documentation on the MSDN site. Is the lifetime (construction and disposition) of the Controller object defined in the ASP.NET MVC Spec?
The reason for this question is to determine whether or not it is safe to store contextual information in Controller members/properties or whether using the HttpContext would be more appropriate.
Given a Java 'File' object, how can I detect whether or not it refers to a symlink?
(If it helps/matters, I know the file refers to a directory, not to a file)
interfaces provide a useful abstraction capability. One can have a class Foo implement some interfaces, say A, B, and C. Some client code may get a reference of type A, others one of type B, etc. each actually the same Foo object but the interface exposing only a narrow subset of the functionality. Of course, evil client code can try to cast the A reference to Foo, then access the other functionality.How to prevent this?
Folks,
I am pulling all my Flash (pure AS3 project, not Flash CS3) content from a Drupal back-end for SEO purposes. This works great, except the HTML rendering built into the TextField object leaves a lot to be desired. Could anyone recommend any libraries that would allow me to display HTML elements? At this stage, commercial or open-source libraries are welcome.
Thanks,
Marcus
whats the correct way to cache a object(DataSet) and then get it and when it expires repopulate it with out a major hiccup in the application... the application relies on this data to be there for read only purposes.
I found this code that is missing the funtion call in thelast line, any ideas on what the save to file command would be?, I'll just kludge it in.
'CODE to SAVE InkPicture to FILE
Dim objInk As MSINKAUTLib.InkPicture
Dim bytArr() As Byte
Dim File1 As String
File1 = "C:\" & TrainerSig & ".gif"
Set objInk = Me.InkPicture2.Object
If objInk.Ink.Strokes.Count > 0 Then
bytArr = objInk.Ink.Save(2)
fSaveFile bytArr, File1
End If
I write vbs that create ole atomation object
On Error Resume Next
dim objShell
dim objFolder
if not objFolder is nothing then
objFolder.CopyHere "ftp://anonymous:[email protected]/bussys"
WScript.Sleep 100
end if
set objShell = nothing
set objFolder = nothing
How to do that on C# (or do that without ole automation just use com) ? Or do that on c++ without MFC.
I have a ItemsControl in a ScrollViewer, and when the items exceed the width of the ScrollViewer they are put into a ContextMenu and shown as a DropDown instead. My problem is that when the Context Menu is first loaded, it saves the saves the size of the Menu and does not redraw when more commands get added/removed.
For example, a panel has 3 commands. 1 is visible and 2 are in the Menu. Viewing the menu shows the 2 commands and draws the control, but then if you resize the panel so 2 are visible and only 1 command is in the menu, it doesn't redraw the menu to eliminate that second menu item. Or even worse, if you shrink the panel so that no commands are shown and all 3 are in the Menu, it will only show the top 2.
Here's my code:
<Button Click="DropDownMenu_Click"
ContextMenuOpening="DropDownMenu_ContextMenuOpening">
<Button.ContextMenu>
<ContextMenu ItemsSource="{Binding Path=MenuCommands}" Placement="Bottom">
<ContextMenu.Resources>
<Style TargetType="{x:Type MenuItem}">
<Setter Property="Command" Value="{Binding Path=Command}" />
<Setter Property="Visibility" Value="{Binding Path=IsVisible, Converter={StaticResource ReverseBooleanToVisibilityConverter}}"/>
</Style>
</ContextMenu.Resources>
<ContextMenu.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding Path=DisplayName}" />
</DataTemplate>
</ContextMenu.ItemTemplate>
</ContextMenu>
</Button.ContextMenu>
</Button>
Code Behind:
void DropDownMenu_ContextMenuOpening(object sender, ContextMenuEventArgs e)
{
Button b = sender as Button;
b.ContextMenu.IsOpen = false;
e.Handled = true;
}
private void DropDownMenu_Click(object sender, RoutedEventArgs e)
{
Button b = sender as Button;
ContextMenu cMenu = b.ContextMenu;
if (cMenu != null)
{
cMenu.PlacementTarget = b;
cMenu.Placement = System.Windows.Controls.Primitives.PlacementMode.Bottom;
}
}
I have tried using InvalidateVisual and passing an empty delegate on Render to try and force a redraw, however neither works. I'm using .Net 4.0.
First, here is the C# code and the disassembled IL:
public class Program<T>
{
private List<T> _items;
public Program(T x, [Microsoft.Scripting.ParamDictionary] Microsoft.Scripting.IAttributesCollection col)
{
_items = new List<T>();
_items.Add(x);
}
}
Here is the IL of that constructor:
.method public hidebysig specialname rtspecialname
instance void .ctor(!T x,
class [Microsoft.Scripting]Microsoft.Scripting.IAttributesCollection col) cil managed
{
.param [2]
.custom instance void [Microsoft.Scripting]Microsoft.Scripting.ParamDictionaryAttribute::.ctor() = ( 01 00 00 00 )
// Code size 34 (0x22)
.maxstack 8
IL_0000: ldarg.0
IL_0001: call instance void [mscorlib]System.Object::.ctor()
IL_0006: nop
IL_0007: nop
IL_0008: ldarg.0
IL_0009: newobj instance void class [mscorlib]System.Collections.Generic.List`1<!T>::.ctor()
IL_000e: stfld class [mscorlib]System.Collections.Generic.List`1<!0> class Foo.Program`1<!T>::_items
IL_0013: ldarg.0
IL_0014: ldfld class [mscorlib]System.Collections.Generic.List`1<!0> class Foo.Program`1<!T>::_items
IL_0019: ldarg.1
IL_001a: callvirt instance void class [mscorlib]System.Collections.Generic.List`1<!T>::Add(!0)
IL_001f: nop
IL_0020: nop
IL_0021: ret
} // end of method Program`1::.ctor
I am trying to understand the IL code by emitting it myself. This is what I have managed to emit:
.method public hidebysig specialname rtspecialname
instance void .ctor(!T A_1,
class [Microsoft.Scripting]Microsoft.Scripting.IAttributesCollection A_2) cil managed
{
// Code size 34 (0x22)
.maxstack 4
IL_0000: ldarg.0
IL_0001: call instance void [mscorlib]System.Object::.ctor()
IL_0006: ldarg.0
IL_0007: newobj instance void class [mscorlib]System.Collections.Generic.List`1<!T>::.ctor()
IL_000c: stfld class [mscorlib]System.Collections.Generic.List`1<!0> class MyType<!T>::_items
IL_0011: ldarg.0
IL_0012: ldfld class [mscorlib]System.Collections.Generic.List`1<!0> class MyType<!T>::_items
IL_0017: ldarg.s A_1
IL_0019: nop
IL_001a: nop
IL_001b: nop
IL_001c: callvirt instance void class [mscorlib]System.Collections.Generic.List`1<!T>::Add(!0)
IL_0021: ret
} // end of method MyType::.ctor
There are a few differences that I just can't figure out. I'm really close...
How do I take care of the parameter attribute (ParamDictionaryAttribute)? I can't find a 'custom' opcode.
Is the .param [2] important? How do I emit that?
Why is the C# code stack size 8, while my emitted version is 4? Is this important?
Hi.
While I do my best to clean JNI objects to free native memory in the end of the usage, there are still some that hang around for a long time, wasting system native memory.
Is there any way to force the GC to give priority in collection of these JNI proxies?
I mean is there a way to cause GC to concentrate on a particular kind of object, namely the JNI proxies?
Thanks.
I have the following File object pointing to a directory via symbolic link,
File directory = new File("/path/symlink/foo/bar");
String[] files = directory.listFiles();
listFiles() returns null, is this because of the symlink? if yes, how will I go about this if I really want to list the files in bar using the path that contains a symlink?
Hi, I have the following XML
<search ver="3.0">
<loc id="ARBA0009" type="1">Buenos Aires, Argentina</loc>
<loc id="BRXX1283" type="1">Buenos Aires, Brazil</loc>
<loc id="ARDF0127" type="1">Aeroparque Buenos Aires, Argentina</loc>
<loc id="MXJO0669" type="1">Concepcion De Buenos Aires, Mexico</loc>
<loc id="MXPA1785" type="1">San Nicolas De Buenos Aires, Mexico</loc>
<loc id="ARBA0005" type="1">Balcarce, Argentina</loc>
<loc id="ARBA0008" type="1">Bragado, Argentina</loc>
<loc id="ARBA0010" type="1">Campana, Argentina</loc>
<loc id="ARBA0016" type="1">Chascomus, Argentina</loc>
<loc id="ARBA0019" type="1">Chivilcoy, Argentina</loc>
</search>
And a City class
public class City {
private String id;
private Integer type;
private String name;
// getters & setters...
}
I tried the following aliases to parse the XML
xStream.alias("search", List.class);
xStream.alias("loc", City.class);
xStream.useAttributeFor("id", String.class);
xStream.useAttributeFor("type", Integer.class);
But I can't figure out how to set the value of the "loc" tag, if I try to transform the City object in XML I get
<search>
<loc id="ARBA0001" type="1">
<name>Buenos Aires</name>
</loc>
</search>
When I really need to get this
<search>
<loc id="ARBA0001" type="1">Buenos Aires</loc>
</search>
Then, if I try to parse the XML to a City object I get the field "name" with a null value.
Anybody knows how to set te correct aliases to do this? Thanks in advance.
I'm just about to use the new EJB3 TimerService (as part of Java EE 6), and as usual, I'm impressed by the brevity of JavaDoc :)
Do you know what is the effect of the persistent property of the TimerConfig object?
JavaDoc TimerConfig says: The persistent property determines whether the corresponding timer has a lifetime that spans the JVM in which it was created. It is optional and defaults to true.
Hi, I have a problem with parameters replacing by Spring JdbcTemplate.
I have this query :
<bean id="fixQuery" class="java.lang.String">
<constructor-arg type="java.lang.String"
value="select fa.id, fi.? from fix_ambulation fa
left join fix_i18n fi
on fa.translation_id = fi.id order by name" />
And this method :
public List<FixAmbulation> readFixAmbulation(String locale) throws Exception {
List<FixAmbulation> ambulations = this.getJdbcTemplate().query(
fixQuery, new Object[] {locale.toLowerCase()},
ParameterizedBeanPropertyRowMapper
.newInstance(FixAmbulation.class));
return ambulations;
}
And I'd like to have the ? filled with the string representing the locale the user is using. So if the user is brasilian I'd send him the column pt_br from the table fix_i18n, otherwise if he's american I'd send him the column en_us.
What I get from this method is a PostgreSQL exception org.postgresql.util.PSQLException: ERROR: syntax error at or near "$1"
If I replace fi.? with just ? (the column name of the locale is unique, so if I run this query in the database it works just fine) what I get is that every object returned from method has the string locale into the field name. I.e. in name field I have "en_us".
The only way to have it working I found was to change the method into :
public List<FixAmbulation> readFixAmbulation(String locale) throws Exception {
String query = "select fa.id, fi." + locale.toLowerCase() + " as name " + fixQuery;
this.log.info("QUERY : " + query);
List<FixAmbulation> ambulations = this.getJdbcTemplate().query(
query,
ParameterizedBeanPropertyRowMapper
.newInstance(FixAmbulation.class));
return ambulations;
}
and setting fixQuery to :
<bean id="fixQuery" class="java.lang.String">
<constructor-arg type="java.lang.String"
value=" from telemedicina.fix_ambulation fa
left join telemedicina.fix_i18n fi
on fa.translation_id = fi.id order by name" />
</bean>
My DAO extends Spring JdbcDaoSupport and works just fine for all other queries. What am I doing wrong?
Hi Guys,
here the following code is used to view the present modal view controller.
[[self navigationController] presentModalViewController:doctorListViewNavigationController animated:YES];
code for dismiss the ModalViewController.
-(void)closeAction
{
[[self navigationController] dismissModalViewControllerAnimated:YES];
}
My problem is the dealloc method is not called then I am getting memory issue problems like object allocations, leaks..
(void)dealloc
{
[doctorList release];
[myTableView release];
[super dealloc];
}
Hi all,
I'm attempting to create a class with many parameters, using a Builder pattern rather than telescoping constructors. I'm doing this in the way described by Joshua Bloch's Effective Java, having private constructor on the enclosing class, and a public static Builder class. The Builder class ensures the object is in a consistent state before calling build(), at which point it delegates the construction of the enclosing object to the private constructor. Thus
public class Foo {
// Many variables
private Foo(Builder b) {
// Use all of b's variables to initialize self
}
public static final class Builder {
public Builder(/* required variables */) {
}
public Builder var1(Var var) {
// set it
return this;
}
public Foo build() {
return new Foo(this);
}
}
}
I then want to add type bounds to some of the variables, and thus need to parametrize the class definition. I want the bounds of the Foo class to be the same as that of the Builder class.
public class Foo<Q extends Quantity> {
private final Unit<Q> units;
// Many variables
private Foo(Builder<Q> b) {
// Use all of b's variables to initialize self
}
public static final class Builder<Q extends Quantity> {
private Unit<Q> units;
public Builder(/* required variables */) {
}
public Builder units(Unit<Q> units) {
this.units = units;
return this;
}
public Foo build() {
return new Foo<Q>(this);
}
}
}
This compiles fine, but the compiler is allowing me to do things I feel should be compiler errors. E.g.
public static final Foo.Builder<Acceleration> x_Body_AccelField =
new Foo.Builder<Acceleration>()
.units(SI.METER)
.build();
Here the units argument is not Unit<Acceleration> but Unit<Length>, but it is still accepted by the compiler.
What am I doing wrong here? I want to ensure at compile time that the unit types match up correctly.
EDIT
It appears the user has to enter some data for his profile, otherwise I get this error below. I guess if there is no profile data, the user can not continue to enter data in other tables by default? I do not want to make entering user profile data a requirement to use the rest of the sites functionality, how can I get around this?
Currently I have been testing everything with the same user and everything has been working fine.
However, when I created a new user for the very first time and tried to enter data into my custom table, I get the following error.
The INSERT statement conflicted with
the FOREIGN KEY constraint
"FK_UserData_aspnet_Profile". The
conflict occurred in database
"C:\ISTATE\APP_DATA\ASPNETDB.MDF",
table "dbo.aspnet_Profile", column
'UserId'. The statement has been
terminated.
Not sure why I am getting this error. I have the user controls set up in ASP.NET 3.5 however all I am using is my own table or at least that I am aware of.
I have a custom UserData table that includes the columns:
id, UserProfileID, CL, LL, SL, DateTime
(id is the auto incremented int) The intent is that all users will add their data in this table and as I mentioned above it has been working fine for my original first user I created. However, when i created a new user I am getting this problem.
Here is the code that updates the database.
protected void Button1_Click(object sender, EventArgs e)
{
//connect to database
MySqlConnection database = new MySqlConnection();
database.CreateConn();
//create command object
Command = new SqlCommand(queryString, database.Connection);
//add parameters. used to prevent sql injection
Command.Parameters.Add("@UID", SqlDbType.UniqueIdentifier);
Command.Parameters["@UID"].Value = Membership.GetUser().ProviderUserKey;
Command.Parameters.Add("@CL", SqlDbType.Int);
Command.Parameters["@CL"].Value = InCL.Text;
Command.Parameters.Add("@LL", SqlDbType.Int);
Command.Parameters["@LL"].Value = InLL.Text;
Command.Parameters.Add("@SL", SqlDbType.Int);
Command.Parameters["@SL"].Value = InSL.Text;
Command.ExecuteNonQuery();
}
Source Error:
Line 84:
Command.ExecuteNonQuery();
I love webpy, it's really quite Pythonic but I don't like having to add the url mappings and create a class, typically with just 1 function inside it.
I'm interested in minimising code typing and prototyping fast.
Does anyone have any up and coming suggestions such as Bobo, Bottle, Denied, cherrypy for a lover of webpy's good things?
What makes it a good reason?
Also I don't mind missing out (strongly) text based templating systems, I use object oriented HTML generation.
CheckPara is my OnDataBinding procedure
SqlDataSource1 is ObjectDataSource (it's only confusing name)
Language is Nemerle, but if you know C# you can read it easy
protected virtual CheckPara(_ : object, _ : System.EventArgs) : void
{
foreach(x is Parameter in SqlDataSource1.SelectParameters)
when(x.DefaultValue=="") //Cancel binding
}
so how can I cancel binding when there is not fully configurated ObjectDataSource ?
Or... how can I run binding only when I done with all parameters ?