Laurent Baye

Greenhorn
+ Follow
since Oct 30, 2006
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Laurent Baye

Thank you for your reply.


To answer your question, i am doing some formatting of the DAO data to my view beans.

ie : date formatting, ...

Now, i have already found my structure which is really basic and consists of having an adapter which takes up a model object and renders a view formatted as i want it.

View <-- Iview
^ ^
| |
Adapter<--IAdapter---> Model



I'll try to post some code later on as i know this probably doesn't make sense at all.

Anyway, if you ever came accross such a problematic, let me know, i am always interested to see what other people try to design.
Hello ,

I am trying my best here to have a proper structure for something that seems somehow very simple:

Basically, i have a Model class and i want to format some of its data before fowarding it to the View.

I also would like to decorelate the view from the model.

Basically the view in this application is some XML output, so it is not interactive.

I thought of two possible patterns :

  • Adapter : the view calls the adapter method which retreives the data from the model (correct me if am wrong).
  • Factory: my controller calls a factory method which takes our model (or its interface) then creates an appropriate view.


  • Which method would you think is better, do you have another solution to this problem?


    I am opened to any suggestions...

    Hi all,

    I've encountered a little pb here:


    =========================================================
    saisie.jsp
    ======================================================================
    <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
    <%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
    <%@ taglib uri="http://myfaces.apache.org/tomahawk" prefix="t"%>


    <f:loadBundle basename="popup" var="msgPopup" />
    <f:loadBundle basename="jourSaisie" var="msgsJourSaisie" />
    <f:loadBundle basename="command" var="msgsCommand" />


    <f:subview id="subviewSaisieTableId">
    <t:saveState value="#{semaineSaisieBean.semaineSaisieId}" />
    <h:inputHidden id="inputSemaineId"
    value="#{semaineSaisieBean.semaineSaisie.semaineSaisieId}" />

    <t:newspaperTable var="rowJour"
    value="#{semaineSaisieBean.semaineSaisie.jourSaisieList}" id="El_pais"
    newspaperColumns="7">
    <h:column>
    <h:panelGrid columns="1" styleClass="table_m" headerClass="th_m"
    rowClasses="td_m">
    <f:facet name="header">
    <h:panelGroup>
    <h:outputText value="#{rowJour.nomDuJour}" />
    <h:outputText value="#{rowJour.dateSaisie}">
    <f:convertDateTime dateStyle="long" type="date" timeZone="GMT+2:00" />
    </h:outputText>
    </h:panelGroup>
    </f:facet>

    <h:panelGrid columns="1">
    <f:facet name="header">
    <h:outputText value="#{msgsJourSaisie.morning}" />
    </f:facet>
    <h:selectOneMenu value="#{rowJour.tempsTravailAM.projetId}"
    styleClass="form" immediate="true">
    <f:selectItem itemLabel="Absence" itemValue="absence" />
    <f:selectItems value="#{ressourceSelectMenuMap.projetMap}" />
    </h:selectOneMenu>
    </h:panelGrid>
    <h:panelGrid columns="1">
    <f:facet name="header">
    <h:outputText value="#{msgsJourSaisie.afternoon}" />
    </f:facet>
    <h:selectOneMenu value="#{rowJour.tempsTravailPM.projetId}"
    styleClass="form" immediate="true">
    <f:selectItem itemLabel="Absence" itemValue="absence" />
    <f:selectItems value="#{ressourceSelectMenuMap.projetMap}" />
    </h:selectOneMenu>
    </h:panelGrid>
    </h:panelGrid>
    </h:column>
    </t:newspaperTable>

    <h:commandButton action="saisie"
    actionListener="#{semaineSaisieBean.saveSemaine}"
    value="#{msgsCommand.save}" styleClass="form" id="saveSemaine" />

    </f:subview>
    ======================================================================



    basically, the aim of this is to save a list of jourSaisie (day entries for a sort of scheduler) with each jourSaisie having a tempsTravailAM/PM (working Time).
    So we have the following objects:
    SemaineSaisie --> jourSaisie --> tempsTravail --> projetId

    We have mapped these in a hibernate(SQL) dB.

    We can create a list of these objects but we can't save the tempsTravailId in the table of jourSaisie (many to one relationship), although we can save the semaineSaisieId in jourSaisie (one to many relationship).

    We think the problem comes form the fact that we have two types of tempsTravail (distinguished by the type element in the TempsTravail.class)


    in case you want to look at our methods :


    this is first called when we get to our page (saisie.jsp)
    =====================================================================
    semaineManager.class
    =====================================================================
    public void saveAllObjectsFromSemaine(SemaineSaisie semaineSaisie) {



    ArrayList jourList = (ArrayList) semaineSaisie.getJourSaisieList();
    ListIterator it = jourList.listIterator();

    SemaineSaisie semaine = (SemaineSaisie) saveReturnObject(semaineSaisie);

    while (it.hasNext ()) {

    JourSaisie jour = (JourSaisie) jourList.get(it.nextIndex());

    TempsTravail travailAm = jour.getTempsTravailAM();
    TempsTravail travailPm = jour.getTempsTravailPM();
    travailAm = (TempsTravail) saveReturnObject(travailAm);
    travailPm = (TempsTravail) saveReturnObject(travailPm);

    jour.setTempsTravailAmId(travailAm.getTempsTravailId());
    jour.setTempsTravailPmId(travailPm.getTempsTravailId());
    jour.setSemaineSaisieId(semaine.getSemaineSaisieId());
    jour.setJourSaisieListIdx(it.nextIndex());

    save(jour);

    it.next();
    }
    }
    =====================================================================




    these are thes methods we call with SemaineSaisieBean.save
    !! But the jsf page never actually gets into it , it just reloads...
    =====================================================================
    SemaineSaisieBean.class
    =====================================================================
    public void saveSemaine(ActionEvent e) {
    System.out.println("START SemaineBean.saveSemaine()");

    /*
    * semaineSaisie.setEmployeId(1); semaineSaisie.setStatut("ouvert");
    * semaineSaisie.setTotalSemaine(1);
    */

    semaineManager.save(semaineSaisie);

    saveJourList(semaineSaisie.getJourSaisieList(), semaineSaisie
    .getSemaineSaisieId());

    System.out.println("END ActionBean.saveAppli()");
    }


    private void saveJourList(List jourList, int id) {

    for (int i = 0; i < jourList.size(); i++) {

    JourSaisie jour = new JourSaisie();

    jour = (JourSaisie) jourList.get(i);

    jour.setJourSaisieId(id);

    TempsTravail travailAm = jour.getTempsTravailAM();
    TempsTravail travailPm = jour.getTempsTravailPM();

    if (jour.getTempsTravailAmId() == 0 && jour.getTempsTravailPmId() == 0) {

    } else {
    travailAm = (TempsTravail) semaineManager
    .saveReturnObject(travailAm);
    travailPm = (TempsTravail) semaineManager
    .saveReturnObject(travailPm);
    jour.setTempsTravailAmId(travailAm.getTempsTravailId());
    jour.setTempsTravailPmId(travailPm.getTempsTravailId());
    }


    semaineManager.save(jour);
    }
    }
    =====================================================================




    thanks for helping. (and reading ;->)

    Laurent &co.

    17 years ago
    JSF