bselect population on first time entry into form

Vijay Balakrishnan <[email protected]>
Newsgroups gmane.comp.java.enhydra.barracuda.general
Message-ID <[email protected]>
Hi,

I am trying to populate a select options box in a  page when i enter the
page for the 
first time.I can see the collection values in the BTemplate but  they are
never rendered on the screen.Only,
the screen mockups show up.I use a event to transfer it from the request to
the render event.
It gets into the viewEvent method but never renders the BSelect with the
values because 
it never goes into the getItem(String key) method. Pardon my ignorance on
the details of the framework.

Any help is greatly appreciated.

Thanks,
Vijay

***********************************************************8
PoolSetup.java 
//class  PoolSetupRenderListener passes it to the
context.getQueue().addEvent(new PoolSetupRenderEvent(context.getEvent()));
   
   
//It gets into the  View Event here within the PoolSetupRenderListener
//and the Collection is populated within the Btemplate and the
PoolSetupModel within it.

public void handleViewEvent(ViewEventContext context):

PoolSetupModel  poolSetupModel = getPoolSetupModel(session);


BTemplate    bodyTemplate = new BTemplate(poolSetupModel);// model has the
collection with values in it


Node         bodyNode = page.getElementPool();//access elemnt pool

TemplateView bodyView = new DefaultTemplateView(bodyNode,"id",
          new MapStateMap(modelProps));

bodyTemplate.setView(bodyView);

try {
       

        bodyTemplate.render(new DefaultViewContext(context));
        
      } catch (RenderException re) {
        logger.warn("Render err:" + re);
      }

new DefaultDOMWriter().write(page,context.getResponse());


*************************************************************

class PoolSetupModel extends AbstractTemplateModel {

public Object getItem(String key) {
        
//it never reaches here when trying to view the page for the first
time###################################################
      if (logger.isDebugEnabled()) {
        logger.debug("[PoolSetupModel.getItem] start");
      }
      ViewContext vc = getViewContext();
      if (key.equals("pool")) { 
//I want to populate a select box with a collection of Pool Objects but it
never comes in here

        DefaultListModel dlm = new DefaultListModel();
        dlm.add(new DefaultItemMap(INVALID_ID,"Select One"));
        pools = getPools();//already exists with a collection of pools
        for (Iterator iter = pools.iterator(); iter.hasNext();) {
          Pool           elementPool = (Pool)iter.next();
          DefaultItemMap dim = new DefaultItemMap(elementPool.getCode(),
              elementPool.getCode() + " -- " + elementPool.getDescr());
          dlm.add(dim);
        }

        BSelect bsPool = new BSelect(dlm);
        bsPool.setEnabled(pools != null && pools.size() > 0);
        bsPool.setDefaultViewContext(vc);   

        return bsPool;
      } else if (key.equals("submit")) {
        return new BInput(BInput.SUBMIT,"submit","Submit");
      } else if (key.equals("formAction")) {
        return new BAction(new PoolSetupSubmitEvent());
      } else {
        return super.getItem(key);
      }
    }

****************************************************************8
Form:

<form id="poolSetupAction" action="PoolSetupSubmitEvent.event"
name="formAction" method="post">
        <table width="100%" border="0" cellspacing="10">
          <tr> 
            <td>
            <select id="pool" Name="poolID" size="1">
              <option selected VALUE="invalidID">Select One </option>
              <option class="discardMe">P1016001 -- Jorge Jimenez</option>
              <option class="discardMe">P1016002 -- Hangers</option>
              <option class="discardMe">P1016003 -- Ewp</option>
            </select>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.