我即将开始使用JSF / Facelets开展项目,该项目将与第三方库集成。
此第三方库包含屏幕定义,它具有以下API:
/** This method gets the screen information**/
public Screen getScreen(int screenId);
/** This method gets the first screen id **/
public int getFirstScreenId();
/** This method submits the screen with the user supplied
values and gets the next screen id **/
public int submitScreen(int screenId, Map<String,Sring> keyValuePair)
throws ScreenValidationException;
“Screen”对象包含控件列表。 “控件”是具有大约25个实现的接口 - 即LabelControl,TextBoxControl,TextAreaControl,DropDownListControl等....
以下是如何使用API从用户收集数据的示例:
第1步:调用getFirstScreenId()==&gt;这将返回第一个屏幕的id以显示给用户。
步骤2:使用屏幕ID
调用getScreen()步骤3:步骤2中返回的Screen对象包含控件列表。显示屏幕的HTML表示,其中包含所有控件(作为HTML表单)给用户。
第4步:用户提交了HTML表单。使用submitScreen()提交值。 第三方库将返回下一个屏幕ID,如果没有更多屏幕要显示,则返回-1。
步骤5:重复步骤2-4,直到submitScreen()返回-1。如果返回-1则意味着 数据收集步骤结束,向用户显示“谢谢”页面。
submitScreen()可以抛出ScreenValidationException - 在这种情况下,重新显示当前屏幕 验证消息存在于ScreenValidationException对象中。
所以,我的问题是如何在这种情况下使用JSF / Facelets显示用户界面?
我可以想象我需要以下
一个托管bean,它具有一个与第三方库进行交互的操作方法。虽然我认为servlet可能最适合这个?
25个奇怪控件的Facelets UI模板(textboxControl,dropdownlistControl等....)
循环遍历“屏幕”对象中的控件并执行
// render the "html form start tag" , i.e, for (Control control : screen.getControls()) { if (control instanceof LabelControl) { // render the LabelControl using the "label template" } else if (control instanceof DropDownListControl) { // render the DropDownListControl using the "dropdownlist template" } ....... } // render the "html form end template" , i.e,
我无法想象如何将这三者放在一起。有人能帮我吗?