Daily Archives

Articles indexed Wednesday January 5 2011

Page 32/35 | < Previous Page | 28 29 30 31 32 33 34 35  | Next Page >

  • How do I replace "this" in Java with something that works.

    - by Luke Alderton
    I'm looking to get the showGUI() method work, the compiler says "this" is not a static variable and cannot be referenced from a static context, what would I use to replace "this"? I've tried test.main (test being the package it's in). The reason I'm using the static method showGUI() is because I need the method to be called from another static method, as well as the startup() method. Below are my two main classes. public class Main extends SingleFrameApplication { @Override protected void startup() { showGUI(); } @Override protected void configureWindow(java.awt.Window root) { } public static Main getApplication() { return Application.getInstance(Main.class); } public static void main(String[] args) { launch(Main.class, args); } public static void showGUI() { show(new GUI(this)); } } public class GUI extends FrameView { public GUI(SingleFrameApplication app) { super(app); initComponents(); } private void initComponents() { //all the GUI stuff is somehow defined here } }

    Read the article

  • Match a comma followed by a newline with a regular expression

    - by MarathonStudios
    I have a comma delimited list I want to import into a database, and in some cases the last item is blank: item1, item2, item3 item1, item2, item1, item2, I'd like to replace all of these empty columns with a placeholder value using a regexp item1, item2, item3 item1, item2, PLACEHOLDER item1, item2, PLACEHOLDER I tried preg_replace("/,\n/", ",PLACEHOLDER\n",$csv);, but this isn't working. Anyone know what regexp would work for this?

    Read the article

  • django join-like expansion of queryset

    - by jimbob
    I have a list of Persons each which have multiple fields that I usually filter what's upon, using the object_list generic view. Each person can have multiple Comments attached to them, each with a datetime and a text string. What I ultimately want to do is have the option to filter comments based on dates. class Person(models.Model): name = models.CharField("Name", max_length=30) ## has ~30 other fields, usually filtered on as well class Comment(models.Model): date = models.DateTimeField() person = models.ForeignKey(Person) comment = models.TextField("Comment Text", max_length=1023) What I want to do is get a queryset like Person.objects.filter(comment__date__gt=date(2011,1,1)).order_by('comment__date') send that queryset to object_list and be able to only see the comments ordered by date with only so many objects on a page. E.g., if "Person A" has comments 12/3/11, 1/2/11, 1/5/11, "Person B" has no comments, and person C has a comment on 1/3, I would see: "Person A", 1/2 - comment "Person C", 1/3 - comment "Person A", 1/5 - comment I would strongly prefer not to have to switch to filtering based on Comments.objects.filter(), as that would make me have to largely repeat large sections of code in the both the view and template. Right now if I tried executing the following command, I will get a queryset returning (PersonA, PersonC, PersonA), but if I try rendering that in a template each persons comment_set will contain all their comments even if they aren't in the date range. Ideally they're would be some sort of functionality where I could expand out a Person queryset's comment_set into a larger queryset that can be sorted and ordered based on the comment and put into a object_list generic view. This normally is fairly simple to do in SQL with a JOIN, but I don't want to abandon the ORM, which I use everywhere else.

    Read the article

  • C# Attributes Aren't Supposed to Inherit

    - by Adam
    Since attributes don't inherit in C# (at least I didn't think they did) - how does the following code still display the Hello popup when the MyTestMethod test is run: [TestClass] public class BaseTestClass { [TestInitialize] public void Foo() { System.Windows.Forms.MessageBox.Show("Hello"); } } [TestClass] public class TestClass : BaseTestClass { [TestMethod] public void MyTestMethod() { Assert.IsTrue(true); } }

    Read the article

  • Thoughts on Static Code Analysis Warning CA1806 for TryParse calls

    - by Tim
    I was wondering what people's thoughts were on the CA1806 (DoNotIgnoreMethodResults) Static Code Analysis warning when using FxCop. I have several cases where I use Int32.TryParse to pull in internal configuration information that was saved in a file. I end up with a lot of code that looks like: Int32.TryParse(someString, NumberStyles.Integer, CultureInfo.InvariantCulture, out intResult); MSDN says the default result of intResult is zero if something fails, which is exactly what I want. Unfortunately, this code will trigger CA1806 when performing static code analysis. It seems like a lot of redundant/useless code to fix the errors with something like the following: bool success = Int32.TryParse(someString, NumberStyles.Integer, CultureInfo.InvariantCulture, out intResult); if (!success) { intResult= 0; } Should I suppress this message or bite the bullet and add all this redundant error checking? Or maybe someone has a better idea for handling a case like this? Thanks!

    Read the article

  • What web browser engine, version, and capabilities are used to display web pages inside Visual Studio 2010?

    - by Phrogz
    My company is developing a plugin/add-on for Visual Studio 2010. When the user asks to display the help for our product, we plan on opening an HTML page (or suite of pages) within Visual Studio. I'm helping to design and implement the help system. What web engine/version is used within Visual Studio 2010? According to Wikipedia it is not Trident(!). Am I allowed to load remote JavaScript content (via a <script> element)? Am I allowed to use XHR to load remote content? Will my page be trusted and have access to the FileSystemObject? I would appreciate any resources you can give me on programming specifically to the 'web' capabilities of VisualStudio2010-as-a-browser.

    Read the article

  • Voicexml how to store input into a global variable

    - by Tyzak
    Hello, I'm creating a voicexml appliacation. I want to store an user input into a global variable. I wondered, the input should be stored in the fieldvar. shouldn't it? After I tried it with this, i tried to store it in an global variable: <assign name="myvar" expr="'myinput'"/> but somehow it didn't work. I used value expr="var" as expr. <?xml version="1.0" encoding="UTF-8"?> <vxml xmlns="http://www.w3.org/2001/vxml" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.w3.org/2001/vxml http://www.w3.org/TR/voicexml20/vxml.xsd" version="2.0"> <var name="myProdukt" /> <form id="test"> <field name="var"> <prompt bargein="true" bargeintype="hotword" >Sagen Sie ein Produkt</prompt> <grammar root="main" version="1.0" xml:lang="de-DE"> <rule id="main" scope="public"> <one-of> <item> p1 </item> <item> p2 </item> <item> p3 </item> <item> p4 </item> </one-of> </rule> </grammar> <filled> <assign name="myProdukt" expr="<value expr="var"/>"/> </filled> </field> </form> <<!--[...] Here i want to use the input.--> </vxml> thanks in advance

    Read the article

  • jndi binding on jboss4.2.3 and ejb3

    - by broschb
    I am trying to deploy a stateless ejb on jboss 4.2.3 using ejb3 annotations. Everything builds and deploys correctly, and I do not get any errors when jboss starts up. However the ejb is not getting bound to any JNDI location for lookup when I look at the bindings in jboss. Below is what I have for my ejb. Remote @Remote public interface TestWebService { public String TestWebMethod(String param1, String param2); } Stateless EJB @Stateless @RemoteBinding(jndiBinding="TestWeb") @Remote(TestWebService.class) public class TestWebServiceBean implements TestWebService{ public String TestWebMethod(String param1, String param2) { System.out.println("HELLO "+param1+" "+param2); return "Welcome!!"; } } I have tried not having the @Remote and @RemoteBinding and it doesn't make a difference. I have also added and ejb-jar.xml file (which should not be needed with ejb3) and that does not appear to make a difference. Below is the output I see in the jboss log on startup. installing MBean: jboss.j2ee:ear=ejb_web_service_ear-0.0.1- SNAPSHOT.ear,jar=ejb_web_service-0.0.1-SNAPSHOT.jar,name=TestWebServiceBean,service=EJB3 with dependencies: 21:56:00,633 INFO [EJBContainer] STARTED EJB: com.tomax.ejb.TestWebServiceBean ejbName: TestWebServiceBean

    Read the article

  • JSF 2.0: Preserving component state across multiple views

    - by tlind
    The web application I am developing using MyFaces 2.0.3 / PrimeFaces 2.2RC2 is divided into a content and a navigation area. In the navigation area, which is included into multiple pages using templating (i.e. <ui:define>), there are some widgets (e.g. a navigation tree, collapsible panels etc.) of which I want to preserve the component state across views. For example, let's say I am on the home page. When I navigate to a product details page by clicking on a product in the navigation tree, my Java code triggers a redirect using navigationHandler.handleNavigation(context, null, "/detailspage.jsf?faces-redirect=true") Another way of getting to that details page would be by directly clicking on a product teaser that is shown on the home page. The corresponding <h:link> would lead us to the details page. In both cases, the expansion state of my navigation tree (a PrimeFaces tree component) and my collapsible panels is lost. I understand this is because the redirect / h:link results in the creation of a new view. What is the best way of dealing with this? I am already using MyFaces Orchestra in my project along with its conversation scope, but I am not sure if this is of any help here (since I'd have to bind the expansion/collapsed state of the widgets to a backing bean... but as far as I know, this is not possible). Is there a way of telling JSF which component states to propagate to the next view, assuming that the same component exists in that view? I guess I could need a pointer into the right direction here. Thanks! Update 1: I just tried binding the panels and the tree to a session-scoped bean, but this seems to have no effect. Also, I guess I would have to bind all child components (if any) manually, so this doesn't seem like the way to go. Update 2: Binding UI components to non-request scoped beans is not a good idea (see link I posted in a comment below). If there is no easier approach, I might have to proceed as follows: When a panel is collapsed or the tree is expanded, save the current state in a session-scoped backing bean (!= the UI component itself) The components' states are stored in a map. The map key is the component's (hopefully) unique, relative ID. I cannot use the whole absolute component path here, since the IDs of the parent naming containers might change if the view changes, assuming these IDs are generated programmatically. As soon as a new view gets constructed, retrieve the components' states from the map and apply them to the components. For example, in case of the panels, I can set the collapsed attribute to a value retrieved from my session-scoped backing bean.

    Read the article

  • RoR custom routing/Method/View problem all methods come back as undefined

    - by Jeff
    I am playing with custom view and routes. I think that I have everything right but obviously not. Essentially I tried to copy the show method and show.html.erb but for some reason it will not work. My controller class fatherController < ApplicationController def show @father = Father.find(params[:id]) respond_to do |format| format.html # show.html.erb format.xml { render :xml => @father } end end def ofmine @father = Father.find(params[:id]) respond_to do |format| format.html # show.html.erb format.xml { render :xml => @father } end end end My routes.rb Parent::Application.routes.draw do resources :fathers do resources :kids end match 'hospitals/:id/ofmine' => 'father#show2' end when I go to 127.0.0.1:/father/1 it works fine but when I try to go to 127.0.0.1:/father/1/ofmine it gives the following error. It doesn't matter what the variable/method that is called; it occurs at the first one to be displayed. Both show.html.erb and show2.html.erb are the exact same files My Error from webserver commandline > Processing by fathersController#show2 > as HTML Parameters: {"id"=>"1"} > Rendered fathers/show2.html.erb within > layouts/application (31.6ms) Completed > in 37ms > > ActionView::Template::Error (undefined > method `name' for nil:NilClass): > 4: <td>Name</td><td></td> > 5: </tr> > 6: <tr> > 7: <td><%= @father.name %></td><td></td> > 8: </tr> > 9: <tr> > 10: <td>City</td><td>State</td> app/views/fathers/show2.html.erb:7:in > `_app_views_fatherss_show__html_erb___709193087__616989688_0' Error as displayed on actual page NoMethodError in Fathers#show2 Showing /var/ruby/chs/app/views/fathers/show2.html.erb where line #7 raised: undefined method `name' for nil:NilClass Extracted source (around line #7): 4: Name 5: 6: 7: <%= @father.name % 8: 9: 10: CityState If anyone could tell me what in the world I am doing wrong I would appreciate it greatly.

    Read the article

  • Using git to sync existing file collection?

    - by chrish
    I've got a collection of files that formerly lived in a Subversion repo; on my new server I've imported them into a git repo so I could start getting more experience with that. On several other machines, I've got mostly up-to-date copies of the existing svn repo files. Is there any way to sync to the new git repo, but use these existing files so I don't have to re-transfer all of the data? Is git smart enough that if I do a fetch? or checkout? that it'll notice the files are identical and not re-transfer them?

    Read the article

  • Monitoring .NET ASP.NET Applications

    - by James Hollingworth
    I have a number of applications running on top of ASP.NET I want to monitor. The main things I care about are: Exceptions: We currently some custom code which will email us when an exception occurs. If the application is failing hard it will crash our outlook... I know (and use) elmah which partly solves the problem however it is still just a big table of exceptions with a pretty(ish) UI. I want something that makes sense of all of these exceptions (e.g. groups exceptions, alerts when new ones occur, tells me what the common ones are that I should fix, etc) Logging: We currently log to files which are then accessible via a shared folder which dev's grep & tail. Does anyone know of better ways of presenting this information. In an ideal world I want to associate it with exceptions. Performance: Request times, memory usage, cpu, etc. whatever stats I can get I'm guessing this is probably going to be solved by a number of tools, has anyone got any suggestions?

    Read the article

  • Writing an AI for a turn-based board game

    - by Cyril
    Hi, i'm currently programming a board game (8x8) in which I need to develop an AI. I have read a lot of articles about AI in board games, minmax with or without alphabeta pruning, but I don't really know how to implements this, I don't know where to start... About my game, this is a turn-based game, each player has pieces on the board, they have to pick one and choose in moving this piece (1 or 2 cells max) or clone the piece (1 cell max). At the moment, I have a really stupid AI which choose a random piece then choose a random move to play... Could you please give me some clues, on how to implement this functionality ? Best regards

    Read the article

  • Drop Down List In A Gridview

    - by Or Betzalel
    I have a gridview, inside the gridview I have a template field and inside that, a drop down list. <asp:TemplateField> <ItemTemplate> <asp:DropDownList ID="Hello" runat="server"> </asp:DropDownList> </ItemTemplate> </asp:TemplateField> I want to databind the gridview but how do I make the drop down list change its value to according to the information I gave it while databinding? Im used to using DataField in bound fields <asp:BoundField HeaderText="Hello" DataField="HelloDB" />

    Read the article

  • what is the best algorithm to use for this problem

    - by slim
    Equilibrium index of a sequence is an index such that the sum of elements at lower indexes is equal to the sum of elements at higher indexes. For example, in a sequence A: A[0]=-7 A[1]=1 A[2]=5 A[3]=2 A[4]=-4 A[5]=3 A[6]=0 3 is an equilibrium index, because: A[0]+A[1]+A[2]=A[4]+A[5]+A[6] 6 is also an equilibrium index, because: A[0]+A[1]+A[2]+A[3]+A[4]+A[5]=0 (sum of zero elements is zero) 7 is not an equilibrium index, because it is not a valid index of sequence A. If you still have doubts, this is a precise definition: the integer k is an equilibrium index of a sequence if and only if and . Assume the sum of zero elements is equal zero. Write a function int equi(int[] A); that given a sequence, returns its equilibrium index (any) or -1 if no equilibrium indexes exist. Assume that the sequence may be very long.

    Read the article

  • How to implement tokenizer.rbegin() and rend() for boost::tokenizer ?

    - by Chan
    Hello everyone, I'm playing around with boost::tokenizer however I realize that it does not support rbegin() and rend(). I would like to ask how can I add these two functions to the existing class? This is from the boost site: #include <iostream> #include <string> #include <boost/tokenizer.hpp> using namespace std; using namespace boost; int main() { string str( "12/12/1986" ); typedef boost::tokenizer<boost::char_separator<char>> tokenizer; boost::char_separator<char> sep( "/" ); tokenizer tokens( str, sep ); cout << *tokens.begin() << endl; // cout << *tokens.rbegin() << endl; How could I implement this? return 0; }

    Read the article

  • serializeArray doesn't include submit-button value

    - by guzh
    Hi, I got two submit buttons in a form. One that deletes the post, and one to edit it. I want to display a fancybox with either the edit-form or a message saying that the user deleted the post. It's all decided by which button was pushed, with a "if(isset)"-sentence in edit.php. However I can't figure out how to get the value of the button within the serializeArray.. I tried with .click(function() instead, but that didn't send anything to the fancybox.. $("#form").bind("submit", function() { $.ajax({ type : "POST", cache : false, url : "edit.php", data : $(this).serializeArray(), success: function(data) { $.fancybox(data); } }); return false; }); The form looks like this: <form method='post' action='' id="form"> <input type='submit' value='Edit' name='edit' /> <input type='submit' value='Delete' name='delete' onClick="return slett('<?php echo $oppgave->name; ?>')"/> <input name='oppgaveID' type='hidden' value='<?php echo $oppgave->id; ?>' /> </form> I would really appreciate it if someone could help me! Thanks in advance!

    Read the article

  • Sharepoint Designer XSLT count boolean node = true

    - by Heather Masters
    I have a SharePoint list I converted to XSLT to do some additional grouping and counting and percentages. I need to return the number of items = true within my nodeset, I have: <xsl:value-of select="count($nodeset/@PartnerArrivedAtCall)"/> (which returns the count of all the nodes) I have tried <xsl:value-of select="count($nodeset/@PartnerArrivedAtCall [@PartnerArrivedAtCall = 'Yes'])"/> (returns zero) and <xsl:variable name="ArrivedYes" select="$nodeset/@PartnerArrivedAtCall [@PartnerArrivedAtCall='Yes']"/> (also returns zero) Can you please give me a good example of how to count only the true values (in my XML, true = "Yes") Thanks!

    Read the article

  • bottle.py on EC2 micro instance causes 2 order of magnitude slowdown

    - by user61633
    Cross-posted from StackOverflow: I wrote a little toy script to solve this type of game, and put it on my new micro EC2 instance. It works perfectly, but while it takes around 0.5 seconds to run a local version, and takes under 0.5 seconds to run both the local and the bottle.py version on my home computer, running the bottle.py version on the EC2 instance takes over 2 minutes. Python has the cpu pegged at 99% the entire time. Only 7.4% memory usage, consistently, and no swapping. The only guess I have is initialization time for bottle.py on EC2, but if it were that, why would it be ~200x faster on my own computer with bottle.py?

    Read the article

  • Is it really necessary to call /bin/sync twice before an unmanaged power-off?

    - by Jeremy Friesner
    Hi all, My company sells an "embedded device" which is implemented as a headless Linux box with ext4 on an internal SSD. Some of our users have a habit of doing a "save current settings" on this box, and then cutting power to the unit as soon as the unit reports that the save completed (ie two seconds later). This was causing occasional corruption of the saved files, as the data wouldn't always get flushed to the SSD before the power went out. So I tweaked my software to run /bin/sync immediately after writing the file (after closing the file handle but before notifying the user that the save completed). This appears to fix the issue, but my coworker says that one call to /bin/sync isn't sufficient, and that to be really safe I ought to run /bin/sync twice in a row. That sounds like paranoia to me... Perhaps a habit from earlier versions of Linux or unix whose sync utility didn't work reliably. Does his advice have merit, or should one call to /bin/sync suffice?

    Read the article

  • Can I force NFS automounts to use NFSv3?

    - by Steve
    I have a linux server that is exporting NFSv4 as well as NFSv3. I have a Fedora14 client that is defaulting to NFSv4 when automounting NFS shares off of the linux server, and it seems to be causing some problems. All my other linux clients on the network are mounting via NFSv3 without issue, so is there a way I can tell automount to mount the share via v3? I am pulling my automount maps via LDAP, with an entry in my /etc/auto.master file like so: +auto_master, so I assume it's a bit different than listing options with a regular automount map? (.i.e. /home --nfsvers=3 fileserver:/DATA)

    Read the article

  • Can I use a Google Appliance/Mini to crawl and index sites I don't own?

    - by SkippyFire
    Maybe this is a stupid question, but... I am working with this company and they said they needed to get "permission" to crawl other people's sites. They have a Google Search Appliance And some Google Minis and want to point them at other sites to aggregate content. The end result will be something like a targeted search engine. (All the indexed sites relate to a specific topic) The only thing they will be doing is: Indexing Content from the other sites/domains Providing search functionality on their own site that searches the indexed content (like Google, displaying summaries and not the full content) The search results will provide links back to the original content Their intent is not malicious in nature, and is to provide a single site/resource for people to reference on their given topic. Is there anything illegal or fishy about this process?

    Read the article

  • Only ONE Outlook 2010 installation "Cannot connect to Exchange server" when setting up new profile.

    - by Johnny PDEX
    Exchange 2010, one-server installation (small production, I know not best practice) OWA Connectivity has been confirmed, Autodiscover is configured and working properly for EVERY other installation. Other user accounts tested on problem Outlook, none can connect. Windows Firewall is pre-configured by Group Policy, only modifications being related to remote management. Firewall has also been disabled during diagnostic period. Network discovery and file sharing is enabled on workstation as well. Windows 7 Professional, latest updates installed. Driving me nuts. Help, serverfault?

    Read the article

  • ConfigurationErrorsException when serving images via UNC on IIS6

    - by Mark Richman
    I have a virtual directory in my web app which connects to a Samba share via UNC. I can browse the files via Windows Explorer without issue, but my web app throws a yellow screen with the following message: Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately. Parser Error Message: An error occurred loading a configuration file: Could not find file '\cluster\cms\qa-images\120400\web.config'. What makes no sense to me is why it's looking for a web.config in that location. I know it's not an authentication issue because the virtual directory can serve images from its root (i.e. \cluster\cms\qa-images\test.jpg serves as http://myserver/upload/test.jpg just fine).

    Read the article

  • Can't connect to ssh after nfs problem

    - by MihaiM
    Hello, I had a problem yesterday with a server that lost connection (S1). From that server, there was a dir shared with NFS to another one (S2), no homedir and not in $PATH, but a dir to store old files for archiving. S1 was back online after a few hours, but now I cannot access S2 because of this (and I'm sure it's because of that because all other services are running without any problem). The ssh connection hangs here: debug1: Entering interactive session. I know a reboot will do the job, but considering this is the NAS of a big app, my bosses will kill me if I do it. Is there any other way to get over this? I tried with different users, but all of them hang in the same place. I connected with HP iLO and not even there I cannot use my username. Thanks in advance.

    Read the article

< Previous Page | 28 29 30 31 32 33 34 35  | Next Page >