Daily Archives

Articles indexed Friday April 23 2010

Page 19/115 | < Previous Page | 15 16 17 18 19 20 21 22 23 24 25 26  | Next Page >

  • Problem with url_for and named routes in ActionMailer View: "Need controller and action"

    - by macek
    I'm attempting to provide a confirmation link in my user welcome email and I'm getting the following Rails error: Need controller and action! It makes a fuss about this line: <p>Please take a moment to activate your account by going to: <%= link_to confirm_user_url(:id => @user.confirmation_code) %>.</p> In my development.rb environment, I have the following line: config.action_mailer.default_url_options = { :host => "localhost", :port => 3000 } There's no problem with the @user variable. I've tested the email with things like @user.username and @user.confirmation_code. I'm only getting trouble with url_for and named routes like confirm_user_url. When I check my routes with rake routes, confirm_user shows up, so it's not an issue with the named route not existing. I can't seem to figure it out. What gives?

    Read the article

  • JFrame that has multiple layers

    - by phunehehe
    Hello, I have a window that has two layers: a static background and a foreground that contains moving objects. My idea is to draw the background just once (because it's not going to change), so I make the changing panel transparent and add it on top of the static background. Here is the code for this: public static void main(String[] args) { JPanel changingPanel = new JPanel() { @Override public void paintComponent(Graphics g) { super.paintComponent(g); g.setColor(Color.RED); g.fillRect(100, 100, 100, 100); } }; changingPanel.setOpaque(false); JPanel staticPanel = new JPanel(); staticPanel.setBackground(Color.BLUE); staticPanel.setLayout(new BorderLayout()); staticPanel.add(changingPanel); JFrame frame = new JFrame(); frame.add(staticPanel); frame.setSize(800, 600); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setVisible(true); } This piece of code gives me the correct image I want, but every time I repaint changingPanel, staticPanel gets repainted as well (which is obviously against the whole idea of painting the static panel just once). Can somebody show me what's wrong? FYI I am using the javax.swing.Timer to recalculate and repaint the changing panel 24 times every second.

    Read the article

  • WPF RelativeSource FindAncestor doesn't work outside of the Control.Resources context?

    - by sker
    I have this VisualBrush resource I took from some site and I apply it with triggers to a TextBox. <VisualBrush x:Key="HelpBrush" TileMode="None" Opacity="0.4" Stretch="None" AlignmentX="Left"> <VisualBrush.Visual> <TextBlock FontStyle="Italic" Text="{Binding Path=Tag, RelativeSource={RelativeSource AncestorType={x:Type Control}, AncestorLevel=1}}"/> </VisualBrush.Visual> </VisualBrush> <Style x:Key="DefaultText" TargetType="TextBox"> <Style.Triggers> <Trigger Property="Text" Value="{x:Null}"> <Setter Property="Background" Value="{StaticResource HelpBrush}"/> </Trigger> <Trigger Property="Text" Value=""> <Setter Property="Background" Value="{StaticResource HelpBrush}"/> </Trigger> </Style.Triggers> </Style> If I place both the VisualBrush and the Style inside the TextBox.Resources tag in XAML, it works fine. But if I take it out and place it in the Window.Resources or a merged dictionary, it stops working. The problem is the Binding, it doesn't find the ancestor TextBox for some reason. I already tried removing AncestorLevel and using AncestorType={x:Type TextBox} - it doesn't work. Any ideas?

    Read the article

  • Writing a plugin for Notepad++

    - by Jukebox
    I use Notepad++ as my main editing tool. I want to write a plugin for it for a feature I'd like to implement, but am unsure of how to go about it. Are there any guides / blogs / tutorials that can point me in the right direction for creating a new plugin?

    Read the article

  • google static maps via TIdHTTP

    - by cloudstrif3
    Hi all. I'm trying to return content from maps.google.com from within Delphi 2006 using the TIdHTTP component. My code is as follows procedure TForm1.GetGoogleMap(); var t_GetRequest: String; t_Source: TStringList; t_Stream: TMemoryStream; begin t_Source := TStringList.Create; try t_Stream := TMemoryStream.Create; try t_GetRequest := 'http://maps.google.com/maps/api/staticmap?' + 'center=Brooklyn+Bridge,New+York,NY' + '&zoom=14' + '&size=512x512' + '&maptype=roadmap' + '&markers=color:blue|label:S|40.702147,-74.015794' + '&markers=color:green|label:G|40.711614,-74.012318' + '&markers=color:red|color:red|label:C|40.718217,-73.998284' + '&sensor=false'; IdHTTP1.Post(t_GetRequest, t_Source, t_Stream); t_Stream.SaveToFile('google.html'); finally t_Stream.Free; end; finally t_Source.Free; end; end; However I keep getting the response HTTP/1.0 403 Forbidden. I assume this means that I don't have permission to make this request but if I copy the url into my web browser IE 8, it works fine. Is there some header information that I need or something else? thanks you advance.

    Read the article

  • Why is visual studio not aware that an integer's value is changing? (debugging)

    - by incrediman
    I have a few simple lines of code (below). [bp] indicates a breakpoint. for(int i=0;i<300;i++){} int i=0; cout<<i; [bp] for (i=0;i<200;i++){} When I debug this in visual studio, it tells me that i is equal to 300 on the breakpoint. Annoyingly, 0 is printed to the console. Is there any way to make it realize that two variables in different scopes can actually have the same name? I also want to add some code to the second loop and then debug it - but when I try to do that, i is consistently shown as 300. Very annoying.

    Read the article

  • Silverlight WCF serialization DataContract(IsReference=true) problem

    - by Ciaran
    Hi, I'm have a Silverlight 3 UI that access WCF services which in turn access respositories that use NHibernate. To overcome some NHibernate lazy loading issues with WCF I'm using my own DataContract surrogate as described here: http://timvasil.com/blog14/post/2008/02/WCF-serialization-with-NHibernate.aspx. In here I'm setting preserveObjectReferences = true My model contains cycles (i.e. Customer with IList[Order]) When I retrieve an object from my service it works fine, however when I try and send that same object back to the wcf service I get the error: System.ServiceModel.CommunicationException was unhandled by user code Message=There was an error while trying to serialize parameter http://tempuri.org/:searchCriteria. The InnerException message was 'Object graph ...' contains cycles and cannot be serialized if references are not tracked. Consider using the DataContractAttribute with the IsReference property set to true.' So cyclical references are now a problem in Silverlight, so I try change my DataContract to be [DataContract(IsReference=true)] but now when I try to retrieve an object from my service I get the following exception: System.ExecutionEngineException was unhandled Message=Exception of type 'System.ExecutionEngineException' was thrown. InnerException: Any ideas?

    Read the article

  • SSRS: Report loading external images, image not found, can I hide the image control

    - by Nauman
    My SSRS report loads logo images for each customer from a customer number specific folder on the report server. I write an expression, to form my URL to the image based on th customer number. ..."http://localhost/images/" + iCustomerNumber.ToString() + "/logo.gif" I am able to get this working, but the problem I face is, when a particular customer doesn't has an image, then my report shows a red X mark in place of the logo. In this case, I expect to hide the image control itself. Any thoughts???? The other dirty solution will be to ensure that each customer specific folder has the designated image! even if there is no logo for a customer, I'll place a blank.gif or a spacer.gif of probably a square pixel in dimension!.

    Read the article

  • Why does presentModalViewController not always work?

    - by E-Madd
    My application requires data from a server in order to run. The first thing it does is displays a view controller (LoadingViewController) that is responsible for checking if the data is saved to my PersistentStoreCoordinator. If the data isn't cached locally, it gets it from my server and caches it, and posts a notification that the LoadingViewController is listening for. When that notification comes through, LoadingViewController presents the application's MainViewController using the presentModalViewController with a flip animation. So far, so good... no errors. However, if the application loads and determines the data IS cached - the presentModalViewController does not work and the main application view never appears. No errors. I've even gone as far as adding a button to the Loading view that executes the same code when pressed and the damn thing works. I'm suspicious it has something to do with the timing of it all but I'm clueless as to what I can do to ensure the view is displayed with that flipping animation if the data is already cached locally. Any suggestions?

    Read the article

  • MVVM/Presentation Model With WinForms

    - by Erik Ashepa
    Hi, I'm currently working on a brownfield application, it's written with winforms, as a preparation to use WPF in a later version, out team plans to at least use the MVVM/Presentation model, and bind it against winforms... I've explored the subject, including the posts in this site (which i love very much), when boiled down, the main advantage of wpf are : binding controls to properties in xaml. binding commands to command objects in the viewmodel. the first feature is easy to implement (in code), or with a generic control binder, which binds all the controls in the form. the second feature is a little harder to implement, but if you inherit from all your controls and add a command property (which is triggered by an internal event such as click), which is binded to a command instance in the ViewModel. The challenges I'm currently aware of are : implementing a commandmanager, (which will trigger the CanInvoke method of the commands as necessery. winforms only supports one level of databinding : datasource, datamember, wpf is much more flexible. am i missing any other major features that winforms lacks in comparison with wpf, when attempting to implement this design pattern? i sure many of you will recommend some sort of MVP pattern, but MVVM/Presentation model is the way to go for me, because I'll want future WPF support. Thanks in advance, Erik.

    Read the article

  • Can this be done using LINQ/Lambda, C#3.0

    - by Newbie
    Objective: Generate dates based on Week Numbers Input: StartDate, WeekNumber Output: List of dates from the Week number specified till the StartDate i.e. If startdate is 23rd April, 2010 and the week number is 1, then the program should return the dates from 16th April, 2010 till the startddate. The function public List<DateTime> GetDates(DateTime startDate,int weeks) { List<DateTime> dt = new List<DateTime>(); int days = weeks * 7; DateTime endDate = startDate.AddDays(-days); TimeSpan ts = startDate.Subtract(endDate); for (int i = 0; i <= ts.Days; i++) { DateTime dt1 = endDate.AddDays(i); dt.Add(dt1); } return dt; } I am calling this function as DateTime StartDate = DateTime.ParseExact("20100423", "yyyyMMdd", System.Globalization.CultureInfo.InvariantCulture); List<DateTime> dtList = GetDates(StartDate, 1); The program is working fine. Question is using C# 3.0 feature like Linq, Lambda etc. can I rewrite the program. Why? Because I am learning linq and lambda and want to implement the same. But as of now the knowledge is not sufficient to do the same by myself. Thanks.

    Read the article

  • How to tell Windows 7 to ignore a default gateway

    - by zildjohn01
    I currently have 2 network cards in my PC -- one connected to an internal network on a router with a disconnected WAN port (10.x.x.x), and one connected to the internet through a consumer router (192.168.0.x). Windows seems to recognize them correctly (my "Network and Sharing Center" lists them as "No Internet" and "Internet" respectively), however when I try browsing the internet it always tries the internal network's default gateway, rather than the one with internet access. Trying to ping a website results in "Reply from 10.0.0.1: Destination net unreachable.". A simple "route delete 0.0.0.0 mask 0.0.0.0 10.0.0.1" fixes the problems, but they return upon reboot, or upon renewing my IP. Is there any way to tell Windows to ignore one NIC's default gateway, or to at least give them priorities?

    Read the article

  • Choose Default Program does not work (is broken) on Windows

    - by Piotr Dobrogost
    For some time now when I click Open with...|Choose Default Program from Windows Explorer's context menu I'm getting this error This file does not have a program associated with it to perform this action. Create an association in the Set Associations control panel. I'm getting this error no matter what the extension of the selected file is. Any ideas how to fix this?

    Read the article

  • Can I use "map" as a substitute for "for each"/"for in"?

    - by John Mee
    For a little while now javascript has the "map" function to loop over arrays. It appears possible to use it as a 'foreach' operator for example: var arr = ['a','b','c'] var doubles = arr.map(function(val){ return val + val }) Is this better or worse than saying for(var i in arr){ ... 50/50: saves having to use the index but adds a callback; it doesn't seem very common so I hesitate to use it but still want to.

    Read the article

  • Iphone contact photo

    - by Kiran
    I tried to search an answer for this but couldn't find one. My iPhone application needs to access the Photo associated with the contact in the phonebook. However, it also needs to make sure that every time application is launched, it verifies that the photo is the same. So, in essence, I am trying to access the photo used by contacts database for a person's phone number or email address. - Is there a way for me to do this? Any help is appreciated.

    Read the article

  • Mutex names - best practice?

    - by Argalatyr
    Related to this question, what is the best practice for naming a mutex? I realize this may vary with OS and even with version (esp for Windows), so please specify platform in answering. My interest is in Win XP and Vista. EDIT: I am motivated by curiousity, because in Rob Kennedy's comment under his (excellent) Answer to the above-linked Question, he implied that the choice of mutex name is non-trivial and should be the subject of a separate question. EDIT2: The referenced question's goal was to ensure only a single instance of an app is running.

    Read the article

  • ASP.NET MVC Routes

    - by MVCDummy09
    Can I see one example that would make this piece of code compile? public IEnumerable<RouteBase> Routes { get { return new List<Route>() { new Route(...) } } } What would you do if RouteCollection.MapRoute() didn't exist? I'm trying to put my Controller in charge of mapping routes, not Global.asax.cs. public IEnumerable<RouteBase> Routes is a member of my Controller. If the Controller is responsible for a Route, it's a bad idea to decouple the Route by using routes.MapRoute() in Global.asax.cs.

    Read the article

< Previous Page | 15 16 17 18 19 20 21 22 23 24 25 26  | Next Page >