Skip to content

Commit

Permalink
Added support for special entity URLs when static HTML is generated.
Browse files Browse the repository at this point in the history
  • Loading branch information
nmihajlovski committed Feb 15, 2015
1 parent 7720ab9 commit fd349b7
Showing 1 changed file with 4 additions and 1 deletion.
Expand Up @@ -7,6 +7,7 @@
import org.rapidoid.annotation.Authors;
import org.rapidoid.annotation.Since;
import org.rapidoid.beany.Beany;
import org.rapidoid.config.Conf;
import org.rapidoid.html.FieldType;
import org.rapidoid.html.FormLayout;
import org.rapidoid.html.HTML;
Expand Down Expand Up @@ -534,10 +535,12 @@ public static boolean isEntity(Object obj) {
}

public static String urlFor(Object entity) {

Long id = Beany.getIdIfExists(entity);
if (id != null) {
String className = Cls.entityName(entity);
return U.format("/%s/%s", U.uncapitalized(className), id);
String frm = Conf.is("generate") ? "%s%s.html" : "/%s/%s";
return U.format(frm, U.uncapitalized(className), id);
} else {
return "";
}
Expand Down

0 comments on commit fd349b7

Please sign in to comment.