private String generateParametersUrl(Object o) { StringBuilder sb = new StringBuilder(); int cpt = 0; logger.debug(o.getClass().getSimpleName()); for (String id : objectManager.getIdName(o.getClass().getSimpleName())) { if (cpt > 0) { sb.append("&"); } sb.append(id); sb.append("="); sb.append(objectManager.getValue(o, id)); cpt++; } return sb.toString(); }
private void showAttributes(Object objet, Map<String, Class> attributes, OutputStream stream) throws IOException { for (Entry<String, Class> attribut : attributes.entrySet()) { stream.write("<td>".getBytes()); Object value = objectManager.getValue(objet, attribut.getKey()); String res = convertor.view(attribut.getValue(), attribut.getKey(), value); stream.write(res.getBytes()); stream.write("</td>".getBytes()); } }
public void show(String entite, Collection<Object> collection, OutputStream stream) { Map<String, Class> attributes = objectManager.getAllAttributes(entite); try { stream.write("<table>".getBytes()); showHeader(attributes, stream); for (Object objet : collection) { stream.write("<tr>".getBytes()); showAttributes(objet, attributes, stream); String parametres = generateParametersUrl(objet); String url = "<td><a href='show.html?" + parametres + "'>Voir</a> "; stream.write(url.getBytes()); url = "<a href='edit.html?" + parametres + "'>Editer</a></td>"; stream.write(url.getBytes()); stream.write("</tr>".getBytes()); } stream.write("</table>".getBytes()); } catch (IOException ex) { logger.fatal(ex); } }