How to call AS2 method from NextFrame(or any other frame) in Flash?
Say you have Action Frame on frame 3, and another one on frame 4, how do you call methods on frame 4 when you are on frame 3.
So here's my conundrum. I am programming a tool that needs to work on old versions of our application. I have the code to the application, but can not alter any of the classes. To pull information out of our database, I have a DTO of sorts that is populated by Hibernate. It consumes a data object for version 1.0 of our app, cleverly named DataObject. Below is the DTO class.
public class MyDTO {
private MyWrapperClass wrapper;
public MyDTO(DataObject data) {
wrapper = new MyWrapperClass(data);
}
}
The DTO is instantiated through a Hibernate query as follows:
select new com.foo.bar.MyDTO(t1.data) from mytable t1
Now, a little logic is needed on top of the data object, so I made a wrapper class for it. Note the DTO stores an instance of the wrapper class, not the original data object.
public class MyWrapperClass {
private DataObject data;
public MyWrapperClass(DataObject data) {
this.data = data;
}
public String doSomethingImportant() { ... version-specific logic ... }
}
This works well until I need to work on version 2.0 of our application. Now DataObject in the two versions are very similar, but not the same. This resulted in different sub classes of MyWrapperClass, which implement their own version-specific doSomethingImportant(). Still doing okay. But how does myDTO instantiate the appropriate version-specific MyWrapperClass? Hibernate is in turn instantiating MyDTO, so it's not like I can @Autowire a dependency in Spring.
I would love to reuse MyDTO (and my dozens of other DTOs) for both versions of the tool, without having to duplicate the class. Don't repeat yourself, and all that. I'm sure there's a very simple pattern I'm missing that would help this. Any suggestions?
In web development, when session state is enabled, a session id is stored in cookie(in cookieless mode, query string will be used instead). In asp.net, the session id is encrypted automatically. There are plenty of topics on the internet regarding how you should encrypt your cookie, including session id. I can understand why you want to encrypt private info such as DOB, but any private info should not be stored in cookie at first place. So for other cookie values such as session id, what is the purpose encryption? Does it add security at all? no matter how you secure it, it will be sent back to server for decryption.
Be be more specific,
For authentication purpose,
turn off session, i don't want to deal with session time out any more
store some sort of id value in the cookie,
on the server side, check if the id value exists and matches, if it is, authenticate user.
let the cookie value expire when browser session is ended, this way.
vs
Asp.net form authentication mechanism (it relies on session or session id, i think)
does latter one offer better security?
Hi,
What is the difference between PrintStream and PrintWriter? They have much methods in common. I always mix up this classes because of that reason. And I think we can use them for exactly the same. But there has to be a difference. Otherwise there was only one class.
I first searched on StackOverflow, but not yet this question.
Thanks
I am fiddling around with JBOSS's Web Services, and I have created the following:
http://127.0.0.1:8080/IM/TestService?wsdl
Now I need to access Web Methods from that Web Service from JavaScript.
Say I have a web method named foo in TestService, how do I make an ajax call to it?
I tried accessing the method via http://127.0.0.1:8080/IM/TestService/foo, but I'm getting an HTTP Status 404.
OK, I know how to create a class extension, using something like that:
on .h
@interface UIButton (myExtensionName)
// my extended methods
@end
and then on .m
@implementation UIButton (myExtensionName)
// my implementations
@end
But how do I declare the extended delegates I may create?
If this was a normal class I would do
@protocol myExtensionName <NSObject>
// my delegate declarations
@end
but how do I do that on a class extension?
thanks
I have mapped a bidirectional many-to-many exception between the entities Course and Trainee in the following manner:
Course
{
...
private Collection<Trainee> students;
...
@ManyToMany(targetEntity = lesson.domain.Trainee.class,
cascade = {CascadeType.All}, fetch = {FetchType.EAGER})
@Jointable(name="COURSE_TRAINEE",
joincolumns = @JoinColumn(name="COURSE_ID"),
inverseJoinColumns = @JoinColumn(name = "TRAINEE_ID"))
@CollectionOfElements
public Collection<Trainee> getStudents() {
return students;
}
...
}
Trainee
{
...
private Collection<Course> authCourses;
...
@ManyToMany(cascade = {CascadeType.All}, fetch = {FetchType.EAGER},
mappedBy = "students", targetEntity = lesson.domain.Course.class)
@CollectionOfElements
public Collection<Course> getAuthCourses() {
return authCourses;
}
...
}
Instead of creating a table where the Primary Key is made of the two foreign keys (imported from the table of the related two entities), the system generates the table "COURSE_TRAINEE" with the following schema:
I am working on MySQL 5.1 and my App. Server is JBoss 5.1.
Does anyone guess why?
Well i have a WCF service and has to methods one that gives a list of a object and one that gives a list of objects..
the object returned from method one is part of the list from method two.
Im using wpf and binding a combo box to the two the results..
but the problem is that the combo box dosent know how to compare the objects as WCF did not generate this for me.. is there some way to fix this??
Hi,
I have resize images exceeding a max size. Methods I tried so far are not good enough :-(
System.Drawing.Image.GetThumbnailImage generates very poor quality images in general.
Playing with options like this one I can generate better images in quality but heavier than the original one.
Probably the second option (or something similar) is the best option and I would need to resize using the proper options.
Any advice?
How to declare an array in method declaration in gen-class?
(ns foo.bar
(:gen-class
:methods [[parseString [String Object] Object]]))
That works fine. But the return type is really an array. How I can declare that so Java can understand it?
What is the correct way of generating random numbers in an ASP.NET MVC application if I need exactly one number per request? According to MSDN, in order to get randomness of sufficient quality, it is necessary to generate multiple numbers using a single System.Random object, created once. Since a new instance of a controller class is created for each request in MVC, I cannot use a private field initialized in the controller's constructor for the Random object. So in what part of the MVC app should I create and store the Random object? Currently I store it in a static field of the controller class and lazily initialize it in the action method that uses it:
public class HomeController : Controller
{
...
private static Random random;
...
public ActionResult Download()
{
...
if (random == null)
random = new Random();
...
}
}
Since the "random" field can be accessed by multiple instances of the controller class, is it possible for its value to become corrupted if two instances attempt to initialize it simultaneously? And one more question: I know that the lifetime of statics is the lifetime of the application, but in case of an MVC app what is it? Is it from IIS startup till IIS shutdown?
Using Visual Studio 2008 and VB.Net:
I have a working web app that uses an ASMX web service which is compiled into its separate assembly. I have another class library project compiled as a separate assembly that serves as a proxy to this web service. This all seems to work at runtime but I am getting this warning at compile time which I don't understand and would like to fix:
Type of member 'wsZipeee' is not CLS-compliant
I have dozens of webforms in the main project that reference the proxy class with no compile time complaints as this snippet shows:
Imports System.Data
Partial Class frmZipeee
Inherits System.Web.UI.Page
Public wsZipeee As New ProxyZipeeeService.WSZipeee.Zipeee
Dim dsStandardMsg As DataSet
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles MyBase.Load
And yet I have one webform (also in the root of the main project) which gives me the "not CLS-compliant" message but yet attempts to reference the proxy class just like the other ASPX files. I get the compile time warning on the line annoted by me with 'ERROR here..
Imports System.Data
Partial Class frmHome
Inherits System.Web.UI.Page
Public wsZipeee As New ProxyZipeeeService.WSZipeee.Zipeee ERROR here
Dim dsStandardMsg As DataSet
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles MyBase.Load
This makes no sense to me. The file with the warning is called frmHome.aspx.vb; all others in the project declare things the same way and have no warning. BTW, the webservice itself returns standard datatypes: integer, string, and dataset.
Hi,
I am working on an iphone application in which I am consuming a webservice.
So i am parsing the XML file data. any idea about how to parse self closing tag
like: State/ and how to read data of self tag like: Contact Email="[email protected]" Name="PhD" Phone="123-521-3388" Source="location"/
I am parsing xml file using NSXMLPARSER class methods and library
Thanks,
I need to put some value to maps if it is not there yet. The key-value (if set) should always be in two collections (that is put should happen in two maps atomically). I have tried to implement this as follows:
private final ConcurrentMap<String, Object> map1 = new ConcurrentHashMap<String, Object>();
private final ConcurrentMap<String, Object> map2 = new ConcurrentHashMap<String, Object>();
public Object putIfAbsent(String key) {
Object retval = map1.get(key);
if (retval == null) {
synchronized (map1) {
retval = map1.get(key);
if (retval == null) {
Object value = new Object(); //or get it somewhere
synchronized (map2) {
map1.put(key, value);
map2.put(key, new Object());
}
retval = value;
}
}
}
return retval;
}
public void doSomething(String key) {
Object obj1 = map1.get(key);
Object obj2 = map2.get(key);
//do smth
}
Will that work fine in all cases? Thanks
We have a C# web app where users will connect using a digital certificate stored in their browsers.
From the examples that we have seen, verifying their identity will be easy once we enable SSL, as we can access the fields in the certificate, using Request.ClientCertificate, to check the user's name.
We have also been requested, however, to sign the data sent by the user (a few simple fields and a binary file) so that we can prove, without doubt, which user entered each record in our database.
Our first thought was creating a small text signature including the fields (and, if possible, the md5 of the file) and encrypt it with the private key of the certificate, but...
As far as I know we can't access the private key of the certificate to sign the data, and I don't know if there is any way to sign the fields in the browser, or we have no other option than using a Java applet. And if it's the latter, how we would do it (Is there any open source applet we can use? Would it be better if we create one ourselves?)
Of course, it would be better if there was any way to "sign" the fields received in the server, using the data that we can access from the user's certificate. But if not, any info on the best way to solve the problem would be appreciated.
Hi all,
Here is my problem, I have a class which have a object who throw an event and in this event I throw a custom event from my class. But unfortunately the original object throw the event from another thread and so my event is also throw on another thread. This cause a exception when my custom event try to access from controls.
Here is a code sample to better understand :
class MyClass
{
// Original object
private OriginalObject myObject;
// My event
public delegate void StatsUpdatedDelegate(object sender, StatsArgs args);
public event StatsUpdatedDelegate StatsUpdated;
public MyClass()
{
// Original object event
myObject.AnEvent += new EventHandler(myObject_AnEvent);
}
// This event is called on another thread
private void myObject_AnEvent(object sender, EventArgs e)
{
// Throw my custom event here
StatsArgs args = new StatsArgs(..........);
StatsUpdated(this, args);
}
}
So when on my windows form I call try to update a control from the event StatsUpdated I get a cross thread exception cause it has been called on another thread.
What I want to do is throw my custom event on the original class thread, so control can be used within it.
Anyone can help me ?
Is it possible to override the to_sentence method just for one model in my rails application?
More generally, how do I modify methods for an Array of my models?
In my windows phone 8 application, while trying to create a dependency property I am always getting this exception. what I am doing wrong, plz guide me.
{System.Windows.Markup.XamlParseException: Failed to create a
'System.Windows.RoutedEventHandler' from the text 'Button_Click'.
[Line: 108 Position: 66] at
System.Windows.Application.LoadComponent(Object component, Uri
resourceLocator) at com.sap.View.HomePage.InitializeComponent()
at com.sap.View.HomePage..ctor()}
this is code-behind of Header
public static readonly DependencyProperty MenuClickProperty = DependencyProperty.Register("MenuClick", typeof(RoutedEventHandler), typeof(Header), new PropertyMetadata(OnMenuClickHandlerChanged));
public RoutedEventHandler MenuClick
{
get { return (RoutedEventHandler)GetValue(MenuClickProperty); }
set { SetValue(MenuClickProperty, new RoutedEventHandler(value)); }
}
private static void OnMenuClickHandlerChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
Header header = d as Header;
header.OnMenuClickHandlerPropertyChanged(e);
}
private void OnMenuClickHandlerPropertyChanged(DependencyPropertyChangedEventArgs e)
{
MenuButton.Click += MenuClick;
}
this is in my user control (Header)
<Button Click="{Binding Path=MenuClick, Source={RelativeSource Mode=Self}}" />
this is how i am including control on my Page:
<myControls:Header Title="{Binding Title}" MenuClick="Button_Click" />
this is in code-behind:
public void Button_Click(object sender, RoutedEventArgs e)
{
OpenSettings();
}
Is there any difference between these two methods of moving a file?
System.IO.FileInfo f = new System.IO.FileInfo(@"c:\foo.txt");
f.MoveTo(@"c:\bar.txt");
//vs
System.IO.File.Move(@"c:\foo.txt", @"c:\bar.txt");
I have put some console.writeline code in to test, but they arent appearing in the output box?
public static ArrayList myDeliveries = new ArrayList();
public mainForm()
{
InitializeComponent();
}
private void mainForm_Load(object sender, EventArgs e)
{
if (!File.Exists("../../MealDeliveries.txt"))
{
MessageBox.Show("File not found!");
return;
}
using (StreamReader sr = new StreamReader("../../MealDeliveries.txt"))
{
//first line is delivery name
string strDeliveryName = sr.ReadLine();
Console.WriteLine("some tetttttttttt23423423423423423ttttttttttttttttttttttt");
while (strDeliveryName != null)
{
//other lines
Delivery d = new Delivery(strDeliveryName, sr.ReadLine(),
sr.ReadLine(), sr.ReadLine(),
sr.ReadLine(), sr.ReadLine(),
sr.ReadLine());
mainForm.myDeliveries.Add(d);
//check for further values
strDeliveryName = sr.ReadLine();
}
}
displayDeliveries();
}
private void displayDeliveries()
{
lstDeliveryDetails.Items.Clear();
Console.WriteLine("some tettttttttttttttttttttttttttttttttt");
Console.WriteLine(mainForm.myDeliveries.Count);
foreach (Delivery d in mainForm.myDeliveries)
{
lstDeliveryDetails.Items.Add(d.DeliveryName);
}
}
Can anyone help??
This may be related to my question from a few days ago, but I'm not even sure how to explain this part. (It's an entirely different parent-child relationship.)
In my interface, I have a set of attributes (Attribute) and valid values (ValidValue) for each one in a one-to-many relationship. In the Spring MVC frontend, I have a page for an administrator to edit these values. Once it's submitted, if any of these fields (as <input> tags) are blank, I remove the ValidValue object like so:
Set<ValidValue> existingValues = new HashSet<ValidValue>(attribute.getValidValues());
Set<ValidValue> finalValues = new HashSet<ValidValue>();
for(ValidValue validValue : attribute.getValidValues()) {
if(!validValue.getValue().isEmpty()) {
finalValues.add(validValue);
}
}
existingValues.removeAll(finalValues);
for(ValidValue removedValue : existingValues) {
getApplicationDataService().removeValidValue(removedValue);
}
attribute.setValidValues(finalValues);
getApplicationDataService().modifyAttribute(attribute);
The problem is that while the database is updated appropriately, the next time I query for the Attribute objects, they're returned with an extra entry in their ValidValue set -- a null, and thus, the next time I iterate through the values to display, it shows an extra blank value in the middle. I've confirmed that this happens at the point of a merge or find, at the point of "Execute query ReadObjectQuery(entity.Attribute).
Here's the code I'm using to modify the database (in the ApplicationDataService):
public void modifyAttribute(Attribute attribute) {
getJpaTemplate().merge(attribute);
}
public void removeValidValue(ValidValue removedValue) {
ValidValue merged = getJpaTemplate().merge(removedValue);
getJpaTemplate().remove(merged);
}
Here are the relevant parts of the entity classes:
Entity
@Table(name = "attribute")
public class Attribute {
@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "attribute")
private Set<ValidValue> validValues = new HashSet<ValidValue>(0);
}
@Entity
@Table(name = "valid_value")
public class ValidValue {
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "attr_id", nullable = false)
private Attribute attribute;
}
i try to write a kind of generic repository to add method.
Everything is ok to add but I have table which is related with two tables with FOREIGN KEY.But Not working because of foreign key
public class DomainRepository<TModel> : IDomainRepository<TModel> where TModel : class
{
#region IDomainRepository<T> Members
private ObjectContext _context;
private IObjectSet<TModel> _objectSet;
public DomainRepository()
{
}
public DomainRepository(ObjectContext context)
{
_context = context;
_objectSet = _context.CreateObjectSet<TModel>();
}
//do something.....
public TModel Add<TModel>(TModel entity) where TModel : IEntityWithKey
{
EntityKey key;
object originalItem;
key = _context.CreateEntityKey(entity.GetType().Name, entity);
_context.AddObject(key.EntitySetName, entity);
_context.SaveChanges();
return entity;
}
//do something.....
}
Calling REPOSITORY:
//insert-update-delete
public partial class AddtoTables
{
public table3 Add(int TaskId, int RefAircraftsId)
{
using (DomainRepository<table3> repTask = new DomainRepository<table3>(new TaskEntities()))
{
return repTask.Add<table3>(new table3() { TaskId = TaskId, TaskRefAircraftsID = RefAircraftsId });
}
}
}
How to add a new value if this table includes foreign key relation
I write a python class which makes asynchronous method calls using D-Bus. When my reply_handler is called, it stores data in list. This list can be used by another class methods at the same time. Is it safe or I can use only synchronized data structures like Queue class?
I have this list
http://pastebin.me/dde64f8c185de9dd5e429f84701a01ce
Anytime you click on an image extra content appears . I have tryed several css methods but i cant get the images to remain in their position and get the text to go underneath . Anyone has a solution ?
Hi Guys,
I need a help from ur side.
Actually I need to call a method automatically when I click on to the textview.
Is there any delegate methods or any other process for this.
Anyone's help will be much appreciated.
Thank you,
Monish.