I figured out one way to do this, and it makes sense.  All you need to
do is load a String[] with the single key values that you want
preselected. This is my getter for the UI:

    public String[] getDocJobOpts() {
        List djoList = Documentjoboption.getList(dbconn.getSession(),
curDocjob.getUid());
        docJobOpts = new String[djoList.size()];
        Iterator iter1 = djoList.iterator();
        Documentjoboption djo;
        int i = 0;
        while (iter1.hasNext()) {
            djo = (Documentjoboption) iter1.next();
            docJobOpts[i] = djo.getOptionuid().toString();
            i++;
        }
        return docJobOpts;
    }

    public void setDocJobOpts(String[] x) {
        this.docJobOpts = x;
    }

    public List getDocumentMediaoptionsSMC() {
        List moList =
Mediatypeoptionasc.getByMediatype(dbconn.getSession(),
curDocjob.getMediatypeuid());
        List djoList = Documentjoboption.getList(dbconn.getSession(),
curDocjob.getUid());
        List smcList = new Vector();

        Mediaoption mo;
        Iterator iter = moList.iterator();
        SelectItem si;
        while (iter.hasNext()) {
            mo = (Mediaoption) iter.next();
            si = new SelectItem(mo.getUid().toString(), mo.getName());
            smcList.add(si);
        }
        return smcList;
    }

<h:selectManyCheckbox id="options" layout="pageDirection"
value="#{MainCtl.docJobOpts}" styleClass="copy" >
    <f:selectItems value="#{MainCtl.documentMediaoptionsSMC}" />
</h:selectManyCheckbox> 


I am adding this to the archive to help others if they have the same problem.

Aaron Bartell


On Fri, 21 Jan 2005 01:11:51 -0600, Aaron Bartell
<[EMAIL PROTECTED]> wrote:
> Hi All,
> 
> I am trying to preload the check in a check box for selectManyCheckbox
> UI component. Below is a link to  Kito Mann's thread where he was
> responding to somebody with the same question. The thing is that I
> cannot get this to work using java.util.List even though Kito says it is
> doable.
> 
> http://www.manning-sandbox.com/thread.jspa?messageID=36236&tstart=0
> 
> Here is my code. getDocJobOpts get's called first and loads a
> java.util.List of mediaoptions from the database that have been
> previously selected by the user. Then getDocumentMediaoptionsSMC is
> called which loads a java.util.List of all the available media options.
> My problem is that the boxes are never checked even though it appears
> that this should work.  THoughts? - Aaron Bartell
> 
> <h:selectManyCheckbox id="options" layout="pageDirection"
> value="#{MainCtl.docJobOpts}" >
>     <f:selectItems value="#{MainCtl.documentMediaoptionsSMC}" />
> </h:selectManyCheckbox>
> 
>     public List getDocJobOpts() {
>         List docJobOpts = new Vector();
>         List djoList = Documentjoboption.getList(dbconn.getSession(),
> curDocjob.getUid());
>         Iterator iter1 = djoList.iterator();
>         Documentjoboption djo;
>         Mediaoption mo;
>         while (iter1.hasNext()) {
>             djo = (Documentjoboption) iter1.next();
>             mo = Mediaoption.getExact(dbconn.getSession(),
> djo.getOptionuid());
>             docJobOpts.add(new SelectItem(new
> SelectItem(mo.getUid().toString(), mo.getName())));
> 
>         }
>         return docJobOpts;
>     }
> 
>     public List getDocumentMediaoptionsSMC() {
>         List moList =
> Mediatypeoptionasc.getByMediatype(dbconn.getSession(),
> curDocjob.getMediatypeuid());
>         List djoList = Documentjoboption.getList(dbconn.getSession(),
> curDocjob.getUid());
>         List smcList = new Vector();
> 
>         Mediaoption mo;
>         Iterator iter = moList.iterator();
>         SelectItem si;
>         while (iter.hasNext()) {
>             mo = (Mediaoption) iter.next();
>             si = new SelectItem(mo.getUid().toString(), mo.getName());
>             smcList.add(si);
>         }
>         return smcList;
>     }
> 


-- 
Aaron Bartell

Reply via email to