Peeing in the ball is a completely normal behavior (unfortunately for us!). It's because they pee in balls (amongst the other issues like ventilation) that you should only allow them to exercise in one for 10-15 minute intervals so that they aren't trapped in there with their own waste. There's really no way to prevent/stop it, the best thing to do would be to instead try a playpen or closely monitored free-ranging. Though hamster balls are debated, and not technically considered unsuitable, they really don't provide much for hamsters in the ways of stimulation and exercise. Plus, balls are considered cruel or even deadly for every other species of rodent, so why are they acceptable in the hamster community? Whether they're dangerous or not though doesn't matter considering the fact that hamsters explore their world by leaving scent trails that they follow, and by examining objects with their whiskers. A ball blocks off both of these abilities which really makes you wonder if it's doing anything at all! There's also the potential for caught toes and nails inside the ventilation slits so if you can avoid using the ball, I would. Playpens can be made fairly easily and for little to no cost at all. You could even use something as simple as a bathtub with a towel laid down and a couple of boxes
In the end, the choice is yours, but it's just a personal opinion of mine that balls don't really offer much. Best wishes!