I think a better idea is to try and duplicate the java action and in one version you have a string return type and in the other you have an integer return type.
Or if you really want only one action you could return an object with 2 different attribute types (String and Integer)
I am not sure about the end goal, the entire context of your problem. If the integer result that's already returned it's needed as a string maybe you could just reuse the same action but convert the integer result into a string result with the 'toString' method. If it's viceversa you could convert the string into an integer with the 'parseInteger' method.
Hope it helps :)