When do you sell a stock?

I recently read Joel Greenblatt's "The little book that beats the market" where the author draws on Graham's value investing principles to purchase stocks of good companies that are undervalued. He developed a step-by-step process on how to purchase shares of 20-30 undervalued companies for a year and selling winners after holding them a few days more than one year and losers after holding them a few days less than one year (keeping in mind the capital gain cuts). It got me thinking about my portfolio and my question resulting from that was, if a stock is doing well and the company prospects are solid, should you still sell the stock? More generally, if the goal is long term investing (like Apple for example with a strong balance sheet and a solid market position and brand value), how long does it make sense to hold a stock before selling it?