My favorites | Sign in
Project Home Wiki Source
READ-ONLY: This project has been archived. For more information see this post.
Search
for
SetUpComboModel  
Updated Oct 4, 2010 by denis.ha...@gmail.com

Setting up a combo model with data returned from the server is one of typical problems faced during business applications development. Within Jibe framework there are several different methods how you can accomplish this task.

First of all, it is possible to set up combo model inline within XML

<component id="someCombo" template="core.field.combo">
     <width>200</width>
     <plugins>jibe.plugins.comboSelectFirst</plugins>
     <comboModel handler="core.comboProvider">
	  <frstKey type="text">
	     <message-key>jibe.firstKey</message-key>  <- From message bundle
          </single>
	  <secondKey type="text">
	     <message-key>jibe.secondKey</message-key>
	  </frame>
     </comboModel>
</component>

Another option is to cache combo model on the client at application start up.

<component id="someCombo" template="core.field.combo">
     <width>200</width>
     <plugins>jibe.plugins.comboSelectFirst</plugins>
     <comboModel>jibe.Cache.myComboModel</comboModel>
</component>
@Cache("myComboModel")
public String myComboModelCache() {
	Map<String, String> model = new LinkedHashMap<String, String>();
	model.put("firstKey", MessageUtil.getMessage("jibe.firstKey"));
	model.put("secondKey", MessageUtil.getMessage("jibe.secondKey"));
	return JibeUtil.getComboModel(model).toString();
}

The drawback of two methods above is that you can not create combo model dynamically, dependent on the context. For that purpose, there is the third method, using param handler to inject combo model into component definition

<component id="someCombo" template="core.field.combo">
     <width>200</width>
     <plugins>jibe.plugins.comboSelectFirst</plugins>
     <comboModel handler="myComboModelProvider"/>
</component>
@ParamHandler("myComboModelProvider")
public String myComboModelProvider(SimpleParam param) {
	Map<String, String> model = new LinkedHashMap<String, String>();
	model.put("firstKey", MessageUtil.getMessage("jibe.firstKey"));
	model.put("secondKey", MessageUtil.getMessage("jibe.secondKey"));
	return JibeUtil.getComboModel(model).toString();
}
Powered by Google Project Hosting