Question

hello I have two URL mappings in java class one is calling on hyperlink and other is on button

on hyperlink I call

@URLAction(mappingId="abc")
//method..
private String hello(){
return null;
}

on button I call

@URLAction(mappingId="def")
//method..
private String hi(){
return null;
}

first time I call hello() on hyperlink it works fine but when I call hi() on button it works fine too but hello() is also called

as in OCPSOFT If the class the annotated method belongs to declares multiple URL mappings using the @URLMappings annotation, the action will be used for each of the mappings. http://ocpsoft.org/docs/prettyfaces/3.3.3/en-US/html/Configuration.html

my Question is that I want call one method on each urlmapping id any idea ?? thnks in advance.

Was it helpful?

Solution

If you submit a JSF form by clicking something like a <h:commandButton>, JSF will always perform a postback, which means that the request will go back to the original page. That's why your method is executed a second time. If you don't want this, you can configure PrettyFaces to skip page action method invocation for postback:

@URLAction(mappingId="abc", onPostback=false)
private String hello(){
    return null;
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top