Daily Archives

Articles indexed Friday November 2 2012

Page 6/15 | < Previous Page | 2 3 4 5 6 7 8 9 10 11 12 13  | Next Page >

  • Is it safe to run multiple XNA ContentManager instances on multiple threads?

    - by Boinst
    My XNA project currently uses one ContentManager instance, and one dedicated background thread for loading all content. I wonder, would it be safe to have multiple ContentManager instances, each in it's own dedicated thread, loading different content at the same time? I'm prompted to ask this question because this article makes the following statement: If there are two textures created at the same time on different threads, they will clobber the other and you will end up with some garbage in the textures. I think that what the author is saying here, is that if I access one ContentManager simultaneously on two threads, I'll get garbage. But what if I have separate ContentManager instances for each thread? If no-one knows the answer already from experience, I'll go ahead and try it and see what happens.

    Read the article

  • Why does my model render differently than its preview?

    - by Raven Dreamer
    I've been importing .fbx files that I made with 3DS Max 2012 into Unity, and it's quite neat to see my models running around in game. However, I can't help but notice that the models, as they're rendered in game, vary substantially from what they look like in the preview (and also what they looked like in 3DS Max). Observe: In-Game Unity Preview 3DS Max My gut tells me that I'm not setting up Unity's lighting system properly. What, then, do I need to do, to either my scene or my model, in order to get the left-most picture to look like the middle one?

    Read the article

  • Adding a short delay between bullets

    - by Sun
    I'm having some trouble simulating bullets in my 2D shooter. I want similar mechanics to Megaman, where the user can hold down the shoot button and a continues stream of bullets are fired but with a slight delay. Currently, when the user fires a bullet in my game a get an almost laser like effect. Below is a screen shot of some bullets being fired while running and jumping. In my update method I have the following: if(gc.getInput().isKeyDown(Input.KEY_SPACE) ){ bullets.add(new Bullet(player.getPos().getX() + 30,player.getPos().getY() + 17)); } Then I simply iterate through the array list increasing its x value on each update. Moreover, pressing the shoot button (Space bar) creates multiple bullets instead of just creating one even though I am adding only one new bullet to my array list. What would be the best way to solve this problem?

    Read the article

  • Page not redirecting -Jquery

    - by RMN
    I have page1.aspx and page2.aspx in a website I need to navigate as: Page1-- Page 2(on click of go back button, back to page1)-- page 1 I am using jQuery code to navigate: var pagename= "page2.aspx"; jQ(location).attr('href', pagename); I tried using same code in page2 to navigate back to page 1: var path2 = "page1.aspx"; jq(location).attr('href', path2); also tried below code and similar few others as well. document.location.pathname = '../Pages/page1.aspx'; But all it does is, navigate me to show Directory Listing, where it shows all page names under pages folder. Is there anything wrong with the code ? I tried to do it as per levels too, that is ../pages/page1.aspx .

    Read the article

  • What is "Android Activity", what is the difference between "BlankActivity", and "MasterDetailFlow"?

    - by Adrianus Hendry
    I want to create an android application using Eclipse Juno, but then i am getting confused of what the "activity" actually is. The first time i created android app project, there was an option that require me to select whether i want to create activity, and if so, i need to choose between BlankActivity and MasterDetailFlow. Also, is it possible that an application has many activities? I think i need some tutorials about creating android application using eclipse, so if you have a good tuts either it is in text or videos i will appreciate it. Actually i am a newbie in mobile apps development, so i wish the answer will be less complex. Thanks in advance.

    Read the article

  • "error: Unexpected error" during maven build with Android Anotations

    - by zasadnyy
    I have problem with building project with android anotations (v.2.6) using maven, with eclipse all works just fine. Here is some project and error details: build configuration snippet from pom: <plugin> <groupId>com.jayway.maven.plugins.android.generation2</groupId> <artifactId>android-maven-plugin</artifactId> <version>3.3.2</version> <inherited>true</inherited> <configuration> <androidManifestFile>${project.basedir}/AndroidManifest.xml</androidManifestFile> <assetsDirectory>${project.basedir}/assets</assetsDirectory> <resourceDirectory>${project.basedir}/res</resourceDirectory> <nativeLibrariesDirectory>${project.basedir}/src/main/native</nativeLibrariesDirectory> <sdk> <platform>16</platform> </sdk> <undeployBeforeDeploy>true</undeployBeforeDeploy> </configuration> </plugin> <plugin> <artifactId>maven-compiler-plugin</artifactId> <version>2.5</version> <inherited>true</inherited> <configuration> <source>1.6</source> <target>1.6</target> </configuration> <extensions>true</extensions> </plugin> and here is output after executing mvn clean install on parent project: [INFO] --- maven-compiler-plugin:2.5:compile (default-compile) @ native-container framework --- [INFO] Compiling 102 source files to /Users/vitaliyzasadnyy/Development/repository/androidcontainer/native-container- android/native-container-framework/target/classes [INFO] ------------------------------------------------------------- [ERROR] COMPILATION ERROR : [INFO] ------------------------------------------------------------- [ERROR] error: Unexpected error. Please report an issue on AndroidAnnotations, with the following content: java.lang.NullPointerException [ERROR] at com.googlecode.androidannotations.internal.codemodel.JCodeModel.ref(JCodeModel.java:372) at com.googlecode.androidannotations.processing.EBeansHolder.refClass(EBeansHolder.java:160) at com.googlecode.androidannotations.processing.EBeansHolder$Classes.<init>(EBeansHolder.java:50) at com.googlecode.androidannotations.processing.EBeansHolder.<init>(EBeansHolder.java:136) at com.googlecode.androidannotations.processing.ModelProcessor.process(ModelProcessor.java:40) at com.googlecode.androidannotations.AndroidAnnotationProcessor.processAnnotations(AndroidAnnotationProcessor.java:472) at com.googlecode.androidannotations.AndroidAnnotationProcessor.processThrowing(AndroidAnnotationProcessor.java:343) at com.googlecode.androidannotations.AndroidAnnotationProcessor.process(AndroidAnnotationProcessor.java:318) at com.sun.tools.javac.processing.JavacProcessingEnvironment.callProcessor(JavacProcessingEnvironment.java:627) at com.sun.tools.javac.processing.JavacProcessingEnvironment.discoverAndRunProcs(JavacProcessingEnvironment.java:556) at com.sun.tools.javac.processing.JavacProcessingEnvironment.doProcessing(JavacProcessingEnvironment.java:701) at com.sun.tools.javac.main.JavaCompiler.processAnnotations(JavaCompiler.java:987) at com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:727) at com.sun.tools.javac.main.Main.compile(Main.java:353) at com.sun.tools.javac.main.Main.compile(Main.java:279) at com.sun.tools.javac.main.Main.compile(Main.java:270) at com.sun.tools.javac.Main.compile(Main.java:87) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.codehaus.plexus.compiler.javac.JavacCompiler.compileInProcess0(JavacCompiler.java:559) at org.codehaus.plexus.compiler.javac.JavacCompiler.compileInProcess(JavacCompiler.java:534) at org.codehaus.plexus.compiler.javac.JavacCompiler.compile(JavacCompiler.java:168) at org.apache.maven.plugin.AbstractCompilerMojo.execute(AbstractCompilerMojo.java:678) at org.apache.maven.plugin.CompilerMojo.execute(CompilerMojo.java:128) at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:101) at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209) at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153) at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59) at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183) at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161) at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:320) at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156) at org.apache.maven.cli.MavenCli.execute(MavenCli.java:537) at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196) at org.apache.maven.cli.MavenCli.main(MavenCli.java:141) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290) at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230) at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409) at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352) /Users/vitaliyzasadnyy/Development/repository/androidcontainer/native-container-android/native-container-framework/src/main/java/com/nravo/framework/activity/MainScreenActivity.java:[44,-1] Unexpected error. Please report an issue on AndroidAnnotations, with the following content: java.lang.NullPointerException at com.googlecode.androidannotations.internal.codemodel.JCodeModel.ref(JCodeModel.java:372) at com.googlecode.androidannotations.processing.EBeansHolder.refClass(EBeansHolder.java:160) Does anybody faced with this problem?

    Read the article

  • cakePHP: Filter selected list by variable

    - by gonzela2006
    I'm on cakePHP 2. I have a problem and I need your help. Here is some code of my controller(StudentsController.php) specifically "edit" function: $students = $this -> Student -> find('list', array( 'order' => 'Student.name ASC' )); $this -> set('students', $students); How can I filter the list by the current student's class?? so the list will contain all students that has the same student's class I need some code like this $students = $this -> Student -> find('list', array( 'conditions' => array('Student.class_id' => CURRENT-STUDENT'S-CLASS), 'order' => 'Student.name ASC' )); $this -> set('students', $students); Please Advise Thanks, gonzela2006

    Read the article

  • Drupal 7 front page URL after changing the front page

    - by Freeman
    I have used Configuration|Site Information|Default Front Page to designate node/55 as my front page. How can I create a menu linking to the original front page, i.e. the one with the list of articles? If I link to <front> it goes to node/55. P.S.: I have been able to simulate this by enabling the frontpage view, but, if possible, it would be more efficient to just link to the original front page URL.

    Read the article

  • How to make IE 9 Standards Mode the default mode?

    - by Evik James
    I have a web site that works perfectly fine in IE9 when compatibility mode is turned OFF (the compatibility symbol is gray). When compatibility mode is turned on (blue), the jQuery doesn't work at all. I have added the following tag to the site to tell the browser that compatibility mode should NOT be used. <meta http-equiv="X-UA-Compatible" content="IE=Edge" > I have the doctype as this: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> Still, the browser doesn't seem to default to standard mode and the user must manually ensure that they are NOT in compatibility mode. Can I disable IE 9 Compatibility Mode? Have I done what I need to do to disable IE 9 Compatibility Mode? Can the user always override IE 9 Standards Mode?

    Read the article

  • Detect response from Modem?

    - by GoodBoyNYC
    I'm working with a Teltonika G10 GSM modem and wrote up a basic program to send out SMS. I put a 1.5 second timer between each AT command to allow the modem to simulate the wait for the "OK" from the modem. This works for now but I'd rather use a branching statement wait for an actual response such as "OK" or "ERROR" rather than using a timer. SerialPort1.Write("AT+CMGD=1,4" & vbCrLf) Thread.Sleep(1250) SerialPort1.Write("AT+CMGF=1" & vbCrLf) Thread.Sleep(1250) SerialPort1.Write("AT+CMGS=" & Chr(34) & "3475558223" & Chr(34) & vbCrLf) Thread.Sleep(1250) SerialPort1.Write(":|" & Chr(26))

    Read the article

  • Multiple fields from LINQ to Text Box

    - by Chuki2
    how can I pass value from selected field (LINQ) to textbox in winforms? If single fields, I just do like this var result = from row in dtValueBranch.AsEnumerable() where row.Field<int>("branchID") == idBranch select row.Field<string>("branchName"); StringBuilder sb = new StringBuilder(); foreach (string s in result) { sb.Append(s + Environment.NewLine); } tbBranch.Text = sb.ToString(); So this is the code LINQ to many fields var result = from row in dtValueBranch.AsEnumerable() where row.Field<int>("branchID") == idBranch select new { BranchName = row["branchName"].ToString(), branchTel = row["branchTel1"].ToString(), // And many more fields }; How can I to implement each fields to each textbox?

    Read the article

  • Samsung Galaxy tab Textbox issue

    - by csharpnewbie
    We are working on a mobile web application( .NET based). We are facing an issue in Samsung galaxy tab text box. Pls find below the details. Let me know if you need more details. Problem in Samsung tab 750 We have a login screen where we focus on the input text box the Samsung tab keypad pops up and the design is completely collapsed. And the same is working fine in iPad. Wanted to check any settings or CSS property to fix this issue. ![After tapping on the text box]

    Read the article

  • Perl: how to pretty-print time duration

    - by sds
    How do I pretty print time duration in perl? The only thing I could come up with so far is my $interval = 1351521657387 - 1351515910623; # milliseconds my $duration = DateTime::Duration->new( seconds => POSIX::floor($interval/1000) , nanoseconds => 1000000 * ($interval % 1000), ); my $df = DateTime::Format::Duration->new( pattern => '%Y years, %m months, %e days, ' . '%H hours, %M minutes, %S seconds, %N nanoseconds', normalize => 1, ); print $df->format_duration($duration); which results in 0 years, 00 months, 0 days, 01 hours, 35 minutes, 46 seconds, 764000000 nanoseconds This is no good for me for the following reasons: I don't want to see "0 years" (space waste) &c and I don't want to remove "%Y years" from the pattern (what if I do need years next time?) I know in advance that my precision is only milliseconds, I don't want to see the 6 zeros in the nanoseconds part. I care about prettiness/compactness/human readability much more than about precision/machine readability. I.e., I want to see something like "1.2 years" or "3.22 months" or "7.88 days" or "5.7 hours" or "75.5 minutes" (or "1.26 hours, whatever looks better to you) or "24.7 seconds" or "133.7 milliseconds" &c (similar to how R prints difftime)

    Read the article

  • CreateProcessWithLogonW : unable to start process

    - by Vivek
    Hi I am completely new to programming. And please someone help me. I am trying to start a pocess from a service. I need to start the new process by prompting user to enter admin credentials. I was trying to use CreateProcessWithLogonW(). Am I using the right function. I tried to give input username, password, domain as localhost. I gave full pathe to the .exe file that i need to start. Here is the piece of code. CreateProcessWithLogonW(L"Administrator", L"localhost", L"password", 0, NULL, L"c:\myupdates\myapp.exe", NORMAL_PRIORITY_CLASS | CREATE_CONSOLE, NULL, NULL, &si, &pi); Si.cb = sizeof(si); Si.lpDesktop = L"winsta0\\default"; But the process never started. Can you guys tell me what I am doing wrong. And what do I need to do to promt user to enter credentials of administrator instead of hardcoding it.

    Read the article

  • SQL GROUP BY - also SELECT not-constant columns

    - by Michal Kosek
    can someone please help me with this query? I have 2 tables in my database: log_visitors: -------------------- id | host_id log_access: -------------------- visitor | document | timestamp "log_access.visitor" links to "log_visitors.id" Currently, I'm using this query: SELECT log_visitors.host_id , MIM(log_access.timestamp) AS min_timestamp FROM log_access INNER JOIN log_visitors ON (log_access.visitor = log_visitors.id) GROUP BY log_visitors.host_id; to get "MIN(timestamp)" for each "host_id" in the database. HERE'S MY QUESTION: I also need to get "document" for that access with that timestamp... I can't simply add "log_access.document" into SELECT list, since it's not constant and I am not grouping by document... Any ideas?

    Read the article

  • Multiple conditions on select query

    - by stats101
    I have a select statement and I wish to calculate the cubic volume based on other values within the table. However I want to check that neither pr.Length_mm or pr.Width_mm or pr.Height_mm are NULL prior. I've looked at CASE statements, however it only seems to evaluate one column at a time. SELECT sa.OrderName, sa.OrderType, pr.Volume_UOM ,pr.Length_mm*pr.Width_mm*pr.Height_mm AS Volume_Cubic ,pr.Length_mm*pr.Width_mm AS Volume_Floor ,pr.Length_mm ,pr.Height_mm ,pr.Width_mm FROM CostToServe_MCB.staging.Sale sa LEFT JOIN staging.Product pr ON sa.ID = pr.ID

    Read the article

  • Jquery mobile spinner not loading in external links

    - by Jorge Zuverza
    I'm developing an application in which I have internal and external links. i noticed that Jquery mobile does not load the spinner when an external link is clicked: Example <a href = "/products">Spinner is shown </a> <a href = "othersite.com" rel = "external">Spinner is NOT shown </a> I have tried : $('a[href][rel=external]').click(function(){ //doesnt work $.mobile.showPageLoadingMsg(); } and: $('a[href][rel=external]').click(function(){ // shows the spinner but it gets stuck forever $.mobile.showPageLoadingMsg(); $('#loadingDiv').div("refresh"); } can someone help me show the spinner when the rel = external links are clicked? thanks!

    Read the article

  • Stringbuilder ignores last space

    - by chead23
    I am initialising a StringBuilder as follows: StringBuilder builder = new StringBuilder("Symptoms are "); After this I loop through a list and add each string item to the end using foreach(var item in list) { builder.Append(item); } An example item would be something like "headache" but once i've appended it to "Symptoms are " and called builder.ToString() it shows: "Symptoms areHeadache...etc" as opposed to "Symptoms are Headache...etc" Why is it ignoring the space?

    Read the article

  • Show Hide Subnav

    - by Jon
    How can I toggle the subnav for each item, and if one is open, hide the open one to show the current one? If there are none shown, just toggle. If you click one and show subnav then and click another hide previous and show current. Here is my html - <header> <div class="content-wrapper"> <div class="user-menu-wrapper"> <div class="hsn-logo"></div> <div class="user-greeting-wrapper"> <div class="user-greeting">Hi, Abraham</div> </div> <div class="user-menu"> <ul class="user-menu-items"> <li>@Html.ActionLink(" ", "Index", "Home", new { @class = "my-account" })</li> <li>@Html.ActionLink(" ", "Index", "Home", new { @class = "my-favorites" })</li> <li>@Html.ActionLink(" ", "Index", "Home", new { @class = "my-bag" })</li> </ul> </div> </div> <div class="hsn-nav-wrapper"> <div class="hsn-nav"> <ul class="hsn-nav-items"> <li style="width: 25%"> <a class="shop" href="#"> <span class="hsn-nav-item-wrap"> <span>SHOP</span><span class="drop-down-arrow"></span> </span> </a> </li> <li style="width: 25%"> <a class="watch" href="#"> <span class="hsn-nav-item-wrap"> <span>WATCH</span><span class="drop-down-arrow"></span> </span> </a> </li> <li style="width: 25%"> <a class="play" href="#"> <span class="hsn-nav-item-wrap"> <span>PLAY</span><span class="drop-down-arrow"></span> </span> </a> </li> <li style="width: 15%"> <a href=""><span class="hsn-search-icon"></span> </a> </li> </ul> </div> <br class="clear" /> </div> </div> </header> <subnav id="shop" class="shop-subnav"> <div class="hsn-subnav-wrapper"> <div class="hsn-subnav"> <div class="hsn-subnav-left"> <ul> <li>SubnavItem</li> <li>SubnavItem</li> <li>SubnavItem</li> <li>SubnavItem</li> <li>SubnavItem</li> <li>SubnavItem</li> <li>SubnavItem</li> <li><span class="hsn-subnav-callout">Deals</span></li> </ul> </div> <div class="hsn-subnav-right"> <ul> <li>SubnavItem</li> <li>SubnavItem</li> <li>SubnavItem</li> <li>SubnavItem</li> <li>SubnavItem</li> <li>SubnavItem</li> <li>SubnavItem</li> <li><span class="hsn-subnav-callout">Clearance</span></li> </ul> </div> </div> </div> </subnav> <subnav id="watch" class="watch-subnav"> <div class="hsn-subnav-wrapper"> <div class="hsn-subnav"> <div class="hsn-subnav-left"> <ul> <li>SubnavItem2</li> <li>SubnavItem2</li> <li>SubnavItem2</li> <li>SubnavItem2</li> </ul> </div> <div class="hsn-subnav-right"> <ul> <li>SubnavItem2</li> <li>SubnavItem2</li> <li>SubnavItem2</li> <li>SubnavItem2</li> </ul> </div> </div> </div> </subnav> Here is my Jquery / JS - $(document).ready(function () { $('ul.hsn-nav-items li a').click(function () { var navitem = $(this).attr('id') , id = $(this).attr('class') , subnav = $('subnav.' + id + '-subnav'); $('a.selected').not(this).removeClass('selected'); $(this).toggleClass('selected'); $('#'+id).toggle(); }); });

    Read the article

  • Hibernate many-to-many relationship

    - by Capitan
    I have two mapped types, related many-to-many. @Entity @Table(name = "students") public class Student{ ... @ManyToMany(fetch = FetchType.EAGER) @JoinTable( name = "students2courses", joinColumns = { @JoinColumn( name = "student_id", referencedColumnName = "_id") }, inverseJoinColumns = { @JoinColumn( name = "course_id", referencedColumnName = "_id") }) public Set<Course> getCourses() { return courses; } public void setCourses(Set<Course> courses) { this.courses = courses; } ... } __ @Entity @Table(name = "courses") public class Course{ ... @ManyToMany(fetch = FetchType.EAGER, mappedBy = "courses") public Set<Student> getStudents() { return students; } public void setStudents(Set<Student> students) { this.students = students; } ... } But if I update/delete Course entity, records are not created/deleted in table students2courses. (with Student entity updating/deleting goes as expected) I wrote abstract class HibObject public abstract class HibObject { public String getRemoveMTMQuery() { return null; } } which is inherited by Student and Course. In DAO I added this code (for delete() method): String query = obj.getRemoveMTMQuery(); if (query != null) { session.createSQLQuery(query).executeUpdate(); } and I ovrerided method getRemoveMTMQuery() for Course @Override @Transient public String getRemoveMTMQuery() { return "delete from students2courses where course_id = " + id + ";"; } Now it works but I think it's a bad code. Is there a best way to solve this problem?

    Read the article

  • httpClient proxy support in apache commons 3.1

    - by user1173339
    I am using apache commons 3.1 to implement httpClient with proxy support. I am trying to connect to a remote host through proxy. The proxy server is configured without any authentication, however the the remote host is configured with authentication. When I am passing the proxy parameters through properties file, it gives warning while execution: WARN - Required proxy credentials not available for BASIC @xx.xx.xx.xx WARN - Preemptive authentication requested but no default proxy credentials availble But the execution goes ahead. On the other hand when I am passing the proxy parameters through the JVM arguments then the again the same warning is given and the execution is stopped. Is there any specific reason for this behavior? Is there any difference in passing the proxy parameters through properties file and through JVM arg? Here is the code: if(System.getProperty("http.proxyHost") != null && System.getProperty("http.proxyPort") != null) { httpClient.getHostConfiguration().setProxy(System.getProperty("http.proxyHost"), Integer.parseInt(System.getProperty("http.proxyPort"))); } else if(AMXAdminTask.props.getProperty("http.proxyHost") != null && AMXAdminTask.props.getProperty("http.proxyPort") != null) { httpClient.getHostConfiguration().setProxy(Propfile.props.getProperty("http.proxyHost"), Integer.parseInt(Propfile.props.getProperty("http.proxyPort"))); }

    Read the article

  • Jersey, JAXB and getting an objectextending an abstract class as a parameter

    - by krajol
    I want to get an object as a parameter of a POST request. I got an abstract superclass that is called Promotion and subclasses Product and Percent. Here's how I try to get a request: @POST @Consumes(MediaType.APPLICATION_XML) @Produces(MediaType.APPLICATION_XML) @Path("promotion/") public Promotion createPromotion(Promotion promotion) { Product p = (Product) promotion; System.out.println(p.getPriceAfter()); return promotion; } and here's how I use JAXB in classes' definitions: @XmlRootElement(name="promotion") @XmlSeeAlso({Product.class,Percent.class}) public abstract class Promotion { //body } @XmlRootElement(name="promotion") public class Product extends Promotion { //body } @XmlRootElement(name="promotion") public class Percent extends Promotion { //body } So the problem now is when I send a POST request with a body like this: <promotion> <priceBefore>34.5</priceBefore> <marked>false</marked> <distance>44</distance> </promotion> and I try to cast it to Product (as in this case, fields 'marked' and 'distance' are from Promotion class and 'priceBefore' is from Product class) I get an Exception: java.lang.ClassCastException: Percent cannot be cast to Product. It seems like Percent is chosen as a 'default' subclass. Why is that and how can I get an object that is a Product?

    Read the article

  • Deep Copy using Reflection in an Extension Method for Silverlight?

    - by didibus
    So I'm trying to find a generic extension method that creates a deep copy of an object using reflection, that would work in Silverlight. Deep copy using serialization is not so great in Silverlight, since it runs in partial trust and the BinaryFormatter does not exist. I also know that reflection would be faster then serialization for cloning. It would be nice to have a method that works to copy public, private and protected fields, and is recursive so that it can copy objects in objects, and that would also be able to handle collections, arrays, etc. I have searched online, and can only find shallow copy implementations using reflection. I don't understand why, since you can just use MemberwiseClone, so to me, those implementations are useless. Thank You.

    Read the article

  • Thin permissions in etc folder (Ubuntu)

    - by Apollo
    I am working on a RoR server setup that uses Thin and Nginx. It works fine, but only if I manually add the folder /etc/thin and set the permissions to 777 in order to use the command below: thin config -C /etc/thin/testapp.yml -c /var/www/testapp --servers 1 -e production If I don't set it to 777, I get this error: me@UbuntuRails:/etc$ thin config -C /etc/thin/testapp.yml -c /var/www/testapp --servers 1 -e production /usr/local/rvm/gems/ruby-1.9.3-p286@rails328/gems/thin-1.5.0/lib/thin/controllers/controller.rb:115:in initialize': Permission denied - /etc/thin/testapp.yml (Errno::EACCES) from /usr/local/rvm/gems/ruby-1.9.3-p286@rails328/gems/thin-1.5.0/lib/thin/controllers/controller.rb:115:inopen' from /usr/local/rvm/gems/ruby-1.9.3-p286@rails328/gems/thin-1.5.0/lib/thin/controllers/controller.rb:115:in config' from /usr/local/rvm/gems/ruby-1.9.3-p286@rails328/gems/thin-1.5.0/lib/thin/runner.rb:187:inrun_command' from /usr/local/rvm/gems/ruby-1.9.3-p286@rails328/gems/thin-1.5.0/lib/thin/runner.rb:152:in run!' from /usr/local/rvm/gems/ruby-1.9.3-p286@rails328/gems/thin-1.5.0/bin/thin:6:in' from /usr/local/rvm/gems/ruby-1.9.3-p286@rails328/bin/thin:19:in load' from /usr/local/rvm/gems/ruby-1.9.3-p286@rails328/bin/thin:19:in' from /usr/local/rvm/gems/ruby-1.9.3-p286@rails328/bin/ruby_noexec_wrapper:14:in eval' from /usr/local/rvm/gems/ruby-1.9.3-p286@rails328/bin/ruby_noexec_wrapper:14:in' I don't like to set this folder to a 777, sounds like a rubbish workaround. I run everything from an admin user account, not root. RVM runs from my admin user and gem only works in my admin as well. If I sudo that action, nothing happens because my root doesn't "know" thin. Which is the correct way to handle this? Thanks!

    Read the article

  • How to catch this low level MySQL (?) error in PHP/Magento

    - by andnil
    When I'm executing the following statement in Magento with a really large $sku, the execution terminates without any errors thrown what so ever. There are no errors in either Magento's, Apache's or PHP's error logs. Mage::getModel('catalog/product')-loadByAttribute('sku', $sku); Question: How do I catch the error? I've tried to set custom error handlers, and for testing purposes I've also managed to trigger error situations where each of the error handler functions are invoked. But when running the previously mentioned Magento code with a large $sku, none of the error handling functions are executed. error_reporting( -1 ); set_error_handler( array( 'Error', 'captureNormal' ) ); set_exception_handler( array( 'Error', 'captureException' ) ); register_shutdown_function( array( 'Error', 'captureShutdown' ) ); For completeness, this is the $sku I'm passing to loadByAttribute(). (The sku is invalid, but that is not the issue) 1- 9685 0102046|1- 9685 1212100|1- 9685 1212092|1- 9685 1212096|1- 9685 1102100|1- 9685 1102108|1- 9685 1102112|1- 9685 1102092|1- 9685 0102048|1- 9685 0102054|1- 9685 0102056|1- 9685 0102058|1- 9685 1212104|1- 9685 1212108|1- 9685 0212058|1- 9685 0104050|1- 9685 0212050|1- 9685 0212056|1- 9685 0212044|1- 9685 0212048|1- 9685 0212052|1- 9685 0212054|1- 9685 1102104|1- 9685 1102124 Any insight into this matter is much appreciated! Update: Upon further investigation, this is the exact point in the code where execution terminates. when the foreach is executed I guess Magento goes into MySQL world and starts loading up data from the database. \Mage\Catalog\Model\Abstract.php public function loadByAttribute($attribute, $value, $additionalAttributes = '*') { $collection = $this->getResourceCollection() ->addAttributeToSelect($additionalAttributes) ->addAttributeToFilter($attribute, $value) ->setPage(1,1); foreach ($collection as $object) { // <--------------- HERE return $object; } return false; } Note, I'm ONLY interested in finding out how to properly CATCH these kinds of errors, not "fix" the logic. This is so that I can present a proper error message to the user. The example above with the malformed sku is contrived and I have no desire to make my Magento app work with those erroneous skus.

    Read the article

< Previous Page | 2 3 4 5 6 7 8 9 10 11 12 13  | Next Page >