Reputation: 16
I have a multiple PrettyFaces annotation on a Managed Bean, how do I determine from which entry point the page was loaded without looking at parameters passed ?
import com.ocpsoft.pretty.faces.annotation.URLAction;
import com.ocpsoft.pretty.faces.annotation.URLMapping;
import com.ocpsoft.pretty.faces.annotation.URLMappings;
@ManagedBean(name = "bean")
@ViewScoped
@URLMappings(mappings = {
@URLMapping(id = "addObject", pattern = "add/type-#{bean.type}", viewId = "/views/object.jsf" ),
@URLMapping(id = "editObject", pattern = "edit/#{bean.objId}", viewId = "/views/object.jsf")
})
public class Bean implements Serializable {
private Long type;
private Long objId;
@URLAction(onPostback = false)
public void load() {
if(objId!=null){
//edit mode
}else{
// add mode
}
}
// getters / setters
}
Upvotes: 0
Views: 332
Reputation: 5668
You can access the ID of the current mapping usind the PrettyContext
like this:
String id = PrettyContext.getCurrentInstance().getCurrentMapping().getId();
Upvotes: 1