:salamext:
The laws for different nations were different at different times. It's likely that the boys who went in the cave were followers of the true religion of Prophet Isa (Jesus son of Mary) peace be upon him - thats why they ran away and hid from their people (so they could worship Allah alone properly), it may have been permissible in that Shari'ah during that time to keep dogs.
However, since the coming of Allah's final Messenger, Muhammad (peace be upon him) - all previous laws are abrogated and the laws revealed to Allah's final Messenger remain in effect uptill the Day of Judgement.