I'm working with JSF 2 and RichFaces. Can I pass some value from bean to oncomplete function in a4j:commandButton? Some counter (int) for example.
You can just use EL in there. It's evaluated on a per request basis.
<a4j:commandButton ... oncomplete="someFunction(#{bean.someIntProperty})" />
Note that this feature is specific to RichFaces components. Standard JSF components (and PrimeFaces) will evalute them on a per view build time only.