Voilà j'ai fait un agent java qui s'exécute à l'ouverture d'un masque. Dans le masque j'y est mis un RichText et grâce à appendstyle, je peux y insérer du html.
Mais bizarrement ça ne marche plus, j'ai du faire une erreur quelques part, mais je n'arrive pas à la trouver.
Voilà le code:
- Code : Tout sélectionner
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Vector;
import lotus.domino.*;
public class JavaAgent extends AgentBase {
public void NotesMain() {
try {
Session session = getSession();
AgentContext agentContext = session.getAgentContext();
String serveur = "********";
String base = "**********";
Document adoc;
// (Your code goes here)
adoc = agentContext.getDocumentContext();
adoc.replaceItemValue("nom", "titi");
RichTextItem richtext;
//richtext = (RichTextItem)adoc.getFirstItem("body");
// richtext = adoc.createRichTextItem("body");
richtext = (RichTextItem)adoc.getFirstItem("body");
richtext.addNewLine();
richtext.appendText("tutu");
RichTextStyle style = session.createRichTextStyle();
style.setPassThruHTML(RichTextStyle.YES);
richtext.appendStyle(style);
richtext.appendText("<style>");
richtext.appendText("table { border : medium solid #000000; width : 80%;}");
richtext.appendText("td,th { border : thin solid #6495ed; width: 10%; }");
richtext.appendText("</style><table>");
richtext.appendText("<th>Horaires</th><th>Lundi</th><th>Mardi</th><th>Mercredi</th>");
richtext.appendText("<th>Jeudi</th><th>Vendredi</th><th>Samedi</th>");
richtext.appendText("<tr><td> 9 H <br> 10 H <br> 11 H <br> 12 H <br> </td>");
richtext.appendText("<td> </td><td> </td><td> </td>");
richtext.appendText("<td> </td><td> </td><td> </td></tr><tr>");
richtext.appendText("<td> 14 H <br> 15 H <br> 16 H <br> 17 H <br> 18 H <br> </td>");
richtext.appendText("<td> </td><td> </td>");
richtext.appendText("<td> </td> <td> </td>");
richtext.appendText("<td> </td> <td> </td> </tr></table>");
Database db = session.getDatabase(serveur,base);
View premvue = db.getView("People");
Document recherche = premvue.getFirstDocument();
String tabutil [] = new String [1000];
int i = 0;
String Add;
String Service;
System.out.println("bonjour !");
while (recherche != null) {
Add = recherche.getItemValueString("MailFile");
Service = recherche.getItemValueString("MailSystem");
if ((Add.indexOf("mail") > -1) && Service.equals("1")) {
tabutil[i] = Add;
}
i = i + 1;
recherche = premvue.getNextDocument(recherche);
}
for (i = 0; i <tabutil> -1 ) {
Db = session.getDatabase(serveur,tabutil[i]);
}
else {
Db = session.getDatabase(serveur,tabutil[i]+".nsf");
}
vueacces = Db.getView("calendar");
System.out.println("On a réussit à ouvrir le calendrier "+ tabutil[i]);
}
catch(Exception e){
continue;
}
Document docc = vueacces.getFirstDocument();
while (docc != null) {
try{
Vector datefin = docc.getItemValueDateTimeArray("EndDate");
DateTime dateagenda = (DateTime)datefin.get(0);
Date date = new Date();
SimpleDateFormat recupannee = new SimpleDateFormat("yyyy");
String anneeactuelle = recupannee.format(date);
String anneeagenda = dateagenda.toString();
anneeagenda = anneeagenda.substring(6,10);
int anactu = Integer.parseInt(anneeactuelle);
int anagenda = Integer.parseInt(anneeagenda);
if (anactu < anagenda) {
System.out.println(docc.getItemValueDateTimeArray("StartDate"));
System.out.println(docc.getItemValueDateTimeArray("EndDate"));
System.out.println(docc.getItemValueDateTimeArray("StartTime"));
System.out.println(docc.getItemValueDateTimeArray("EndTime"));
System.out.println(docc.getItemValueString("Subject"));
}
}
catch(Exception e){
}
docc = vueacces.getNextDocument(docc);
}
}
} catch(Exception e) {
e.printStackTrace();
}
}
}
Merci d'avance pour votre aide =)