Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/388.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/jsf/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 使用Facelets/JSF显示动态视图_Java_Jsf_Facelets - Fatal编程技术网

Java 使用Facelets/JSF显示动态视图

Java 使用Facelets/JSF显示动态视图,java,jsf,facelets,Java,Jsf,Facelets,我即将开始一个使用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

我即将开始一个使用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;
/**此方法获取屏幕信息**/
公共屏幕getScreen(int screenId);
/**此方法获取第一个屏幕id**/
public int getFirstScreenId();
/**此方法提交用户提供的屏幕
值并获取下一个屏幕id**/
public int submitScreen(int screenId,Map keyValuePair)
抛出ScreenValidationException;
“Screen”对象包含控件列表。“控件”是一个大约有25个实现的接口 -即LabelControl、TextBoxControl、TextArea Control、DropDownList Control等

以下是如何使用API从用户收集数据的示例:

步骤1:调用getFirstScreenId()==>这将向用户返回要显示的第一个屏幕的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个控件(textboxControl、DropDownList控件等)的Facelets UI模板

  • 循环通过“Screen”对象中的控件并执行以下操作的代码

  • //呈现“html表单开始标记”,即, for(控件:screen.getControls()){ if(LabelControl的控件实例) { //使用“标签模板”呈现LabelControl } else if(DropDownList控件的控件实例) { //使用“dropdownlist模板”呈现dropdownlist控件 } ....... } //呈现“html表单结束模板”,即, 我无法想象我如何将这三者结合在一起。有人能帮我吗

    // 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,