jsf面试题_JSF面试问答

jsf面试题

I have written a lot on JSF framework recently, so it’s high time I write one on JSF interview questions and answers. Below is my collection of JSF interview questions with answers. So just go through them before interview and I am sure it will help you out in clearing the JSF interview and land you a job. Note that it’s for JSF 2, not JSF 1.

我最近在JSF框架上写了很多东西,所以现在是时候写有关JSF面试问题和答案的文章了 。 以下是我收集的JSF面试问题及其答案 。 因此,在面试之前先对他们进行检查,我相信这将帮助您清除JSF面试并找到工作。 请注意,它用于JSF 2,而不是JSF 1。

JSF面试问题 (JSF Interview Questions)

  1. What is JSF?

    什么是JSF?
  2. What is a Managed Bean?

    什么是托管豆?
  3. What are the three types of text fields tags provided by JSF?

    JSF提供的三种类型的文本字段标签是什么?
  4. What is the significance of @ManagedProperty annotation?

    @ManagedProperty批注的意义是什么?
  5. What does @ApplicationScoped annotation indicate?

    @ApplicationScoped注释表示什么?
  6. What is Resource bundling in JSF?

    JSF中的资源捆绑是什么?
  7. Explain the required and requiredMessage attribute of the <h:inputText> tag?

    解释<h:inputText>标记的required和requiredMessage属性吗?
  8. What are the different types of Page Navigation supported in JSF?

    JSF支持哪些不同类型的页面导航?
  9. What are JSF life cycle phases?

    JSF生命周期阶段是什么?
  10. Explain some of the attributes of <h:form> tag?

    解释<h:form>标记的某些属性?
  11. What are the command component tags used for action and navigation?

    用于操作和导航的命令组件标签是什么?
  12. What are Data Bound table components ?

    什么是数据绑定表组件?
  13. What is an event?

    什么事
  14. How can we obtain the generated event?

    我们如何获得生成的事件?
  15. What are the different types of JSF events?

    JSF事件有哪些不同类型?
  16. What is a listener class?

    什么是听众课?
  17. What is the significance of facelets tag?

    facelets标签的意义是什么?
  18. What are some of the facelets tags?

    什么是facelets标签?
  19. What are the different types of validations in JSF?

    JSF中有哪些不同类型的验证?
  20. What are different types of expressions supported by JSF EL?

    JSF EL支持哪些不同类型的表达式?
  21. What are immediate and deferred value expressions?

    什么是立即值和递延值表达式?
  22. Explain value expression and method expressions?

    解释值表达式和方法表达式?
  23. Explain @ViewScoped, @SessionScoped, @CustomScoped and @RequestScoped annotations?

    解释@ ViewScoped,@ SessionScoped,@ CustomScoped和@RequestScoped批注?
  24. Explain different ways of declaring a managed bean in JSF?

    解释在JSF中声明托管bean的不同方法吗?
  25. What is the significance of name and eager attributes in managed bean?

    托管Bean中的名称和渴望属性的意义是什么?
  26. Mention some of the validator tags used in JSF?

    是否提到了JSF中使用的一些验证器标签?
  27. What are the benefits of using JSF Framework?

    使用JSF Framework有什么好处?
  28. What are different JSF Converter tags?

    有哪些不同的JSF Converter标签?
  29. List the benefits of Expression Language?

    列出表达语言的好处?
  30. What is a backing bean?

    什么是后盾?
  31. What are standard JSF tag libraries?

    什么是标准JSF标签库?
  32. Mention some of the functions that the backing bean method performs?

    提到后备bean方法执行的一些功能?
  33. What are different implementations of JSF API?

    JSF API有哪些不同的实现?
  34. Explain JSF architecture?

    解释JSF架构?
  35. How different components are rendered in JSF page?

    JSF页面中如何呈现不同的组件?
  36. Can the JSF support multiple faces configuration files?

    JSF可以支持多个face配置文件吗?
  37. What are the differences between a Backing Bean and Managed Bean?

    Backing Bean和Managed Bean之间有什么区别?
  38. How to display error messages in JSF?

    如何在JSF中显示错误消息?
  39. What is the significance of selectOne menu tag in JSF?

    JSF中的selectOne菜单标签有什么意义?
  40. Explain immediate and rendered attributes?

    解释立即属性和渲染属性?
  41. Mention two ways of binding supported by JSF?

    提到JSF支持的两种绑定方式?
  42. What are required configurations for JSF framework?

    JSF框架需要哪些配置?
  43. What is JSF Navigation Rule?

    什么是JSF导航规则?
  44. What is the role of JSF converter tags?

    JSF转换器标签的作用是什么?
  45. List the benefits of data table tags in JSF?

    列出JSF中数据表标签的好处?
  46. How to implement internationalization (i18n) in JSF?

    如何在JSF中实现国际化(i18n)?
  47. What is component rendering model?

    什么是组件渲染模型?
  48. What is a render kit?

    什么是渲染工具包?
  49. What is view object?

    什么是视图对象?
  50. What do you mean by Bean Scope?

    Bean Scope是什么意思?
  51. What is the difference between JSF-1 and JSF-2?

    JSF-1和JSF-2有什么区别?
  52. Can we have a JSF application without faces-config.xml?

    我们可以拥有没有faces-config.xml的JSF应用程序吗?
  53. What are some of the best practices for JSF application?

    JSF应用程序有哪些最佳实践?
  54. How do you compare JSF with Spring Framework?

    您如何将JSF与Spring框架进行比较?
  55. Why JSF is not so popular as MVC framework like Spring MVC, even though its older?

    为什么JSF尽管不如Spring MVC那样像MVC框架那样流行?
  56. Can we integrate JSF with other popular frameworks such as Spring, Hibernate etc?

    我们可以将JSF与其他流行的框架(例如Spring,Hibernate等)集成吗?

JSF面试问答 (JSF Interview Questions and Answers)

  1. 什么是JSF? (What is JSF?)

    Java Server Faces (JSF) technology is a front end framework which makes the creation of user interface components easier by reusing the UI components. JSF is designed based on the Model View Controller pattern (MVC) which segregates the presentation, controller and the business logic.

    For getting started with JSF, please read JSF Tutorial for Beginners.

    Java Server Faces(JSF)技术是一个前端框架,通过重用UI组件,可以更轻松地创建用户界面组件。 JSF是基于模型视图控制器模式(MVC)设计的,该模型将表示,控制器和业务逻辑分开。

    要开始使用JSF,请阅读JSF入门教程

  2. 什么是托管豆? (What is a Managed Bean?)

    A managed bean is a java class registered to JSF which makes interaction between the UI and the business logic possible. Managed Beans can be created using @ManagedBean annotation. For a detailed example, please read JSF Managed Bean Example.

    托管bean是注册到JSF的Java类,它使得UI与业务逻辑之间的交互成为可能。 可以使用@ManagedBean批注创建托管Bean。 有关详细的示例,请阅读JSF Managed Bean Example

  3. JSF提供的三种类型的文本字段标签是什么? (What are the three types of text fields tags provided by JSF?)

    The three types of text field tags are;

    1. <h:inputText> – This adds the text box next to the label field.
    2. <h:inputSecret> – This type is used for password fields where the entered data is hidden.
    3. <h:inputTextarea> – This type of fields is used while entering large number of characters.

    For complete example, please go through JSF Text Components.

    文本字段标签的三种类型是:

    1. <h:inputText> –这将在标签字段旁边添加文本框。
    2. <h:inputSecret> –此类型用于密码字段,其中输入的数据被隐藏。
    3. <h:inputTextarea> –输入大量字符时使用此类型的字段。

    有关完整的示例,请浏览JSF Text Components

  4. @ManagedProperty批注的意义是什么? (What is the significance of @ManagedProperty annotation?)

    The @ManagedProperty annotation enables us to inject a managed bean into another managed bean. To learn how it works, please read JSF Injecting Managed Bean.

    @ManagedProperty批注使我们能够将一个托管Bean注入另一个托管Bean中。 要了解其工作原理,请阅读JSF Injecting Managed Bean

  5. @ApplicationScoped注释表示什么? (What does @ApplicationScoped annotation indicate?)

    The @ApplicationScoped annotation indicates that the bean is valid as long as the web application is valid.

    @ApplicationScoped批注表示只要Web应用程序有效,该Bean就有效。

  6. JSF中的资源捆绑是什么? (What is Resource bundling in JSF?)

    The phenomenon of storing the UI labels, date, status messages and other UI textual elements in a separate properties file instead of hardcoding these in a page is called resource bundling.

    We can use h:outputLabel element to pick these values from resource bundle properties file in JSF view pages, for a complete example please refer JSF Resource Bundle Example.

    将UI标签,日期,状态消息和其他UI文本元素存储在单独的属性文件中,而不是在页面中对其进行硬编码的现象称为资源捆绑。

    我们可以使用h:outputLabel元素从JSF视图页面的资源包属性文件中选择这些值,有关完整示例,请参阅JSF Resource Bundle Example

  7. 解释<h:inputText>标记的required和requiredMessage属性吗? (Explain the required and requiredMessage attribute of the <h:inputText> tag?)

    Required attribute indicates that the field is mandatory when set to true. The requiredMessage attribute allows users to specify their own message for the ui components when the fields are mandatory. They are used for declarative validations in JSF view pages, for a complete example please read JSF Declarative Validation.

    必需属性表示当设置为true时该字段是必填字段。 当字段为必填字段时,requiredMessage属性允许用户为ui组件指定自己的消息。 它们用于JSF视图页面中的声明式验证,有关完整示例,请阅读JSF声明式验证

  8. JSF支持哪些不同类型的页面导航? (What are the different types of Page Navigation supported in JSF?)

    The types of Page navigation supported in JSF are

    1. Implicit Navigation
    2. Navigation through Managed Bean
    3. Navigation through faces-config.xml
    4. Forward versus Redirect navigation
    5. Conditional Navigation

    For detailed explanation, please go through JSF Navigation Rules and JSF Action Method Navigation Rule Example.

    JSF支持的页面导航类型为

    1. 隐式导航
    2. 通过托管Bean导航
    3. 通过faces-config.xml导航
    4. 转发与重定向导航
    5. 条件导航

    有关详细说明,请仔细阅读“ JSF导航规则”和“ JSF操作方法导航规则示例”

  9. JSF生命周期阶段是什么? (What are JSF life cycle phases?)

    There are six lifecycle phases namely;

    1. Restore view phase
    2. Apply request values phase
    3. Process validations phase
    4. Update model values phase
    5. Invoke application phase
    6. Render response phase

    For better understanding and detailed explanation of each of life cycle phase, please read JSF Page Lifycycle Management.

    有六个生命周期阶段,即:

    1. 恢复视图阶段
    2. 应用请求值阶段
    3. 流程验证阶段
    4. 更新模型值阶段
    5. 调用应用程序阶段
    6. 渲染响应阶段

    为了更好地理解和详细解释生命周期的每个阶段,请阅读JSF Page Lifycycle Management

  10. 解释<h:form>标记的某些属性? (Explain some of the attributes of <h:form> tag?)

    Some of the important h:form tag attributes are;

    • id: This is the unique identifier used to identify a component.
    • title: A title for an element of the form used as tooltip.
    • onclick: invokes the javascript function to be called when a button is clicked next to an element.
    • onsubmit: invokes javascript function to be called on click of form by a submit button.
    • onreset: Javascript to be invoked on the reset of the elements in a form.
    • ondblclick: Javascript code to be executed when the mouse is double clicked over a field in a form.
    • onmouseup: Javascript code to be executed when the mouse button is released over a component.
    • onmousedown: Javascript code to be executed when the mouse pointer is clicked down over this element.
    • binding: value of the expression linked to a property in a backing bean.
    • target: Name of the frame where the resource retrieved is to be displayed.
    • accept: the contents list that the form can handle.
    • acceptCharSet: defines the list of character encoding that the form will accept.
    • style: The CSS style definitions that can be applied for the form
    • prependId: flag that indicates whether id should be prepended to the form
    • dir: Overrides default text functionality for this component.

    To see form component in action, please go through JSF Form Component Example.

    一些重要的h:form标签属性是;

    • id:这是用于标识组件的唯一标识符。
    • title:用作工具提示的表单元素的标题。
    • onclick:当单击元素旁边的按钮时,调用要调用的javascript函数。
    • onsubmit:通过单击提交按钮调用要在表单单击时调用的javascript函数。
    • onreset:重置表单元素时要调用的Javascript。
    • ondblclick:在表单的字段上双击鼠标时要执行的Javascript代码。
    • onmouseup:在组件上释放鼠标按钮时要执行的Javascript代码。
    • onmousedown:在该元素上单击鼠标指针时要执行的Javascript代码。
    • 绑定:链接到支持bean中的属性的表达式的值。
    • target:将在其中显示检索到的资源的框架的名称。
    • accept:表单可以处理的内容列表。
    • acceptCharSet:定义表单将接受的字符编码列表。
    • style:可应用于表单CSS样式定义
    • prependId:标志,指示是否应在表单之前添加id
    • dir:覆盖此组件的默认文本功能。

    要查看实际使用的表单组件,请仔细阅读JSF Form Component Example

  11. 用于操作和导航的命令组件标签是什么? (What are the command component tags used for action and navigation?)

    The command component tags for performing action and navigation are

    1. <h:commandButton> tag – The h:commandButton tag renders a button to submit a form thereby paving a way for processing the data entered by the user.
    2. <h:commandLink> tag – The commandLink provides an hyperlink equivalent to anchor tag in HTML that acts like a submit button and can be associated with the backing beans or action class for event handling.

    For detailed example, please go through JSF Command Components Example.

    用于执行操作和导航的命令组件标签是

    1. <h:commandButton>标记– h:commandButton标记呈现用于提交表单的按钮,从而为处理用户输入的数据铺平了道路。
    2. <h:commandLink>标记– commandLink提供与HTML中的锚标记等效的超链接,其作用类似于提交按钮,并且可以与后备bean或操作类关联以进行事件处理。

    有关详细的示例,请浏览JSF Command Components Example

  12. 什么是数据绑定表组件? (What are Data Bound table components?)

    The components that are responsible for displaying the relational data in a tabular format are called data bound table components. The <h:dataTable> tag is used for displaying the data components. The <h:column> tag iterates over each record in the data source displayed in rows.

    Some of the attributes of the h:dataTable tag are;

    • bgcolor: background color for the table that is displayed.
    • border: width in pixel to be drawn around the table.
    • cellpadding: Space between border of each cell and its contents.
    • cellspacing: Space between left side of the table and leftmost column and also amount of space between the cells.
    • columnClasses: List of css styles separated by comma to be applied to the columns of this table.
    • bodyrows: List of row indices separated by comma to be applied for the “tbody” element should be started.

    To see dataTable tag in action, please read JSF dataTable tag.

    负责以表格格式显示关系数据的组件称为数据绑定表组件。 <h:dataTable>标记用于显示数据组件。 <h:column>标记遍历行中显示的数据源中的每个记录。

    h:dataTable标记的一些属性是;

    • bgcolor:显示的表格的背景色。
    • border:要在表格周围绘制的宽度(以像素为单位)。
    • cellpadding:每个单元格的边框与其内容之间的空间。
    • cellspacing:表格左侧和最左列之间的空间,以及单元格之间的空间量。
    • columnClasses:CSS样式列表,以逗号分隔,以应用于此表的列。
    • bodyrows:应以逗号分隔的行索引列表应用于“ tbody”元素。

    要查看运行中的dataTable标签,请阅读JSF dataTable标签

  13. 什么事 (What is an event?)

    An event is defined as a signal triggered based upon the user actions such as click of button, hyperlink, changing the input value etc. JSF tells the component to invoke the appropriate listener class that process the event generated by the user.

    事件定义为基于用户操作(例如单击按钮,超链接,更改输入值等)触发的信号。JSF告诉组件调用处理用户生成的事件的适当侦听器类。

  14. 我们如何获得生成的事件? (How can we obtain the generated event?)

    The generated event can be obtained by calling event.getComponent as

    UIComponent ui = new UIComponent();
    MyFacesEvent ev1 = new MyFacesEvent(ui);
    UIComponent sc1 = ev1.getComponent();

    可以通过将event.getComponent调用为

  15. JSF事件有哪些不同类型? (What are the different types of JSF events?)

    There are three types of JSF events namely

    1. Action Events: Action events are the events that are generated for the ui components like command button or command hyperlink.
    2. Value Change Events: Value change events refers to the UI components textfield, radio button, list box etc. The value change event will get fired as soon as the value is changed in the UI component.
    3. Phase Events: This type of event involves the events to be fired in one of the six phases of JSF lifecycle either during start or towards the end of each phase.

    You can get more details about these events at JSF Events Example.

    JSF事件有三种类型,即

    1. 动作事件:动作事件是为ui组件(如命令按钮或命令超链接)生成的事件。
    2. 值更改事件:值更改事件是指UI组件的文本字段,单选按钮,列表框等。值更改事件将在UI组件中更改后立即触发。
    3. 阶段事件:这种类型的事件涉及在每个阶段的开始或结束时在JSF生命周期的六个阶段之一中触发的事件。

    您可以在JSF Events Example中获得有关这些事件的更多详细信息。

  16. 什么是听众课? (What is a listener class?)

    A class which is associated with an event is called a listener class. For example, if the event is a valueChange event then the corresponding listener class ValueChangeListener is associated with it.
    Read more at JSF Listeners Example to learn more about these listeners.

    与事件关联的类称为侦听器类。 例如,如果事件是valueChange事件,则将相应的侦听器类ValueChangeListener与之关联。
    在“ JSF侦听器示例”中了解更多信息,以了解有关这些侦听器的更多信息。

  17. facelets标签的意义是什么? (What is the significance of facelets tag?)

    JSF provides a special set of tags that gives the flexibility to manage common tags/parts in one place for more than one application. These tags allow us to create a common layout that can be used across applications. You can include facelets tags using below code;

    <html
       xmlns="https://www.w3.org/1999/xhtml"
       xmlns:ui="https://java.sun.com/jsf/facelets"
    >

    I have written a very long article for facelets tags, go check it out at JSF Facelets Tags Example.

    JSF提供了一组特殊的标记,这些标记提供了灵活性,可以在一个地方管理多个应用程序中的通用标记/部件。 这些标签使我们能够创建可在应用程序之间使用的通用布局。 您可以使用以下代码包含facelets标签;

    我为facelets标签写了很长的文章,请在JSF Facelets Tags Example上查看。

  18. 什么是facelets标签? (What are some of the facelets tags?)

    Some of the important facelets tags are;

    • <ui:component> tag
    • <ui:composition> tag
    • <ui:decorate> tag
    • <ui:define> tag
    • <ui:fragment> tag
    • <ui:include> tag

    一些重要的facelets标签是;

    • <ui:component>标签
    • <ui:composition>标记
    • <ui:decorate>标签
    • <ui:define>标记
    • <ui:fragment>标记
    • <ui:include>标签
  19. JSF中有哪些不同类型的验证? (What are the different types of validations in JSF?)

    There are two types of validations namely;

    1. Declarative Validations: The validations that are fired using JSF standard validators or Bean validators fall under declarative type.
    2. Imperative validation: The standard validation messages would not be sufficient in all the cases and sometimes may require complex validations that are declared by the user overriding the standard validations and these are called Imperative validations.

    Check out complete details of these validation types at JSF Validation Example.

    有两种验证类型:

    1. 声明式验证 :使用JSF标准验证器或Bean验证器触发的验证属于声明式类型。
    2. 强制性验证 :标准验证消息在所有情况下都不够,有时可能需要由用户声明的复杂验证,而不是标准验证,这些被称为命令性验证。

    在“ JSF验证示例”中检查这些验证类型的完整详细信息。

  20. JSF EL支持哪些不同类型的表达式? (What are different types of expressions supported by JSF EL?)

    JSF Expression Language supports following types of expressions.

    1. Immediate value expressions
    2. Deferred value expressions
    3. Value expression and method expression

    Check out complete details about these at JSF EL Tutorial.

    JSF表达式语言支持以下类型的表达式。

    1. 立即值表达式
    2. 递延值表达式
    3. 值表达式和方法表达式

    JSF EL Tutorial中查看有关这些内容的完整详细信息。

  21. 什么是立即值和递延值表达式? (What are immediate and deferred value expressions?)

    Immediate expressions are evaluated and results are rendered as soon as the page is displayed initially. The syntax for immediate evaluation is ${}.

    Deferred expressions are evaluated during the lifecycle phase whenever it is requested by the user. The syntax for deferred evaluation is #{expression}.

    最初显示该页面时,将立即评估立即表达式并呈现结果。 立即评估的语法为${}

    每当用户请求时,都会在生命周期阶段评估延迟表达式。 延迟评估的语法为#{expression}

  22. 解释值表达式和方法表达式? (Explain value expression and method expressions?)

    Value expressions usually fetch a value or set a value. These expressions can be further categorized into rvalue and lvalue expressions. lvalue expressions can both read and write data whereas rvalue expressions can only read data.

    A method expression allows user to invoke a public method of the bean that returns the result necessary for validating the data component and handling events.

    值表达式通常获取值或设置值。 这些表达式可以进一步分为右值和左值表达式。 左值表达式可以读取和写入数据,而右值表达式只能读取数据。

    方法表达式允许用户调用Bean的公共方法,该方法返回验证数据组件和处理事件所需的结果。

  23. 解释@ ViewScoped,@ SessionScoped,@ CustomScoped和@RequestScoped批注? (Explain @ViewScoped, @SessionScoped, @CustomScoped and @RequestScoped annotations?)

    @ViewScoped: annotation indicates that the bean is alive as long as the user interacts with the same JSF view page in the browser.
    @SessionScoped: annotation indicates that the bean is valid as long as the HTTP session is alive.
    @CustomScoped: annotation indicates that the bean lives as long as the bean’s entry in the custom Map which is created for this scope lives.
    @RequestScoped: annotation indicates that the Bean lives as long as the HTTP request-response lives.

    @ViewScoped :注释表示只要用户与浏览器中的同一JSF视图页面进行交互,该Bean仍处于活动状态。
    @SessionScoped :注释表示只要HTTP会话仍处于活动状态,该bean就有效。
    @CustomScoped :注释指示该bean的生存时间与为此范围创建的自定义Map中的bean条目生存的时间一样长。
    @RequestScoped :注释指示Bean的生存时间与HTTP请求响应的生存时间相同。

  24. 解释在JSF中声明托管bean的不同方法吗? (Explain different ways of declaring a managed bean in JSF?)

    1. Use @ManagedBean annotation in the java class indicating that the class is a managed bean as;
      @ManagedBean(name="Greetings", eager="true")

      If the name attribute is not specified the name is defaulted to the class name as java naming standards. For example class Car will be named “car” and CarDetails will be named “carDetails”.

    2. Declare the managed bean in faces-config.xml file as;

    1. 在java类中使用@ManagedBean批注,指示该类为托管Bean,如:
      @ManagedBean(name="Greetings", eager="true")

      如果未指定name属性,则该名称默认为类名称,作为java命名标准。 例如,类Car将被命名为“ car”,而CarDetails将被命名为“ carDetails”。

    2. 在faces-config.xml文件中将托管Bean声明为;
  25. 托管Bean中的名称和渴望属性的意义是什么? (What is the significance of name and eager attributes in managed bean?)

    name: The name attribute indicates the managed bean with the name specified. If the name is not specified then the bean name is same as the class name.

    eager: If eager is set to “true” then managed bean is created before it is requested for the first time and if set to false the bean is created when it is requested.

    name :name属性指示具有指定名称的托管bean。 如果未指定名称,则Bean名称与类名称相同。

    eager :如果eager设置为“ true”,则在第一次请求托管bean之前创建它,如果设置为false,则在请求bean时创建它。

  26. 是否提到了JSF中使用的一些验证器标签? (Mention some of the validator tags used in JSF?)

    • f:validateLength: Validates length of a string
    • f:validateLongRange: Validates range of numeric value
    • f:validateDoubleRange: Validates range of float value
    • f:validateRegex: Validate JSF component with a given regular expression

    • f:validateLength:验证字符串的长度
    • f:validateLongRange:验证数值范围
    • f:validateDoubleRange:验证浮点值的范围
    • f:validateRegex:使用给定的正则表达式验证JSF组件
  27. 使用JSF Framework有什么好处? (What are the benefits of using JSF Framework?)

    Some of the benefits of using JSF framework are;

    • Clean separation between presentation and business logic.
    • Manages UI state across multiple server requests.
    • Implementation of custom components.
    • Easier flow of data between the components.
    • JSF specs that helps custom implementations such as PrimeFaces

    使用JSF框架的一些好处是;

    • 表示和业务逻辑之间的清晰分离。
    • 管理多个服务器请求中的UI状态。
    • 实现自定义组件。
    • 组件之间的数据流更容易。
    • 帮助自定义实现(例如PrimeFaces)的JSF规范
  28. 有哪些不同的JSF Converter标签? (What are different JSF Converter tags?)

    • f:convertNumber: tag is used to convert a string value to a number of required format.
    • f:convertDateTime: tag is used to convert a string value to a date of required format.
    • CustomConverter: allows user to define their own convertor in JSF.

    • f:convertNumber:标记用于将字符串值转换为多种所需格式。
    • f:convertDateTime:标记用于将字符串值转换为所需格式的日期。
    • CustomConverter:允许用户在JSF中定义自己的转换器。
  29. 列出表达语言的好处? (List the benefits of Expression Language?)

    • Arithmetic, logical, relational operations can be used in expression language.
    • Automatic type conversion.
    • Shows missing values as empty strings instead of NullPointerException.
    • Provides easy access to predefined objects such as request.

    • 可以在表达式语言中使用算术,逻辑,关系运算。
    • 自动类型转换。
    • 将缺少的值显示为空字符串,而不是NullPointerException。
    • 提供对预定义对象(例如请求)的轻松访问。
  30. 什么是后盾? (What is a backing bean?)

    A JavaServer Faces application includes one or more backing beans, each of which is a type of managed bean that can be associated with the components used in a particular page.

    JavaServer Faces应用程序包括一个或多个支持bean,每个支持bean都是一种可与特定页面中使用的组件相关联的托管bean。

  31. 什么是标准JSF标签库? (What are standard JSF tag libraries?)

    1. JSF Core Tags library
    2. JSF HTML tags library

    Use below namespace configurations to use them in JSF xhtml pages.

    <html xmlns="https://www.w3.org/1999/xhtml"
        xmlns:h="https://java.sun.com/jsf/html"
        xmlns:ui="https://java.sun.com/jsf/facelets"
        xmlns:c="https://java.sun.com/jsf/core">

    The html tags can now be used as with the h prefix as <h:head>,<h:form> etc and core tags with c prefix as <c:validateBean>,<c:validator> etc.

    1. JSF核心标签库
    2. JSF HTML标签库

    使用以下名称空间配置在JSF xhtml页面中使用它们。

    现在可以使用html标签,并且将h前缀用作<h:head>,<h:form>等,并将具有c前缀的核心标签用作<c:validateBean>,<c:validator>等。

  32. 提到后备bean方法执行的一些功能? (Mention some of the functions that the backing bean method performs?)

    • Validating a component’s data
    • Handling an event fired by a component
    • Performs processing to determine the next page to which the application must navigate

    • 验证组件的数据
    • 处理组件触发的事件
    • 执行处理以确定应用程序必须导航到的下一页
  33. JSF API有哪些不同的实现? (What are different implementations of JSF API?)

    • ADF Faces: Oracle’s implementation for the JSF standard.
    • Reference Implementation (RI): by Sun Microsystems.
    • Apache MyFaces: open source JavaServer Faces (JSF) implementation.
    • Primefaces: JSF components with Ajax framework.

    • ADF Faces:Oracle对JSF标准的实现。
    • 参考实现(RI):Sun Microsystems提供。
    • Apache MyFaces:开源JavaServer Faces(JSF)实现。
    • Primefaces:具有Ajax框架的JSF组件。
  34. 解释JSF架构? (Explain JSF architecture?)

    JSF is developed based on the Model View Controller(MVC) pattern. The Model VIew Controller separates the business logic from presentation.

    The JSF application contains

    • UI components represented as stateful objects on the server
    • Server-side helper classes
    • Validators, event handlers, and navigation handlers
    • Application configuration resource file for configuring application resources
    • JavaBeans components as models containing application-specific functionality and data
    • A custom tag library for representing event handlers and validators
    • A custom tag library for rendering UI components

    Below image shows the JSF applications architecture diagram.

    JSF是基于模型视图控制器(MVC)模式开发的。 模型模型控制器将业务逻辑与表示分离。

    JSF应用程序包含

    • UI组件表示为服务器上的有状态对象
    • 服务器端帮助程序类
    • 验证器,事件处理程序和导航处理程序
    • 用于配置应用程序资源的应用程序配置资源文件
    • JavaBeans组件作为模型,包含特定于应用程序的功能和数据
    • 一个自定义标签库,用于表示事件处理程序和验证程序
    • 用于呈现UI组件的自定义标签库

    下图显示了JSF应用程序体系结构图。

  35. JSF页面中如何呈现不同的组件? (How different components are rendered in JSF page?)

    JSF components are rendered in the xhtml pages by the tag libraries included, such as JSF core, html and facelets tag libraries.

    JSF组件通过包含的标记库(例如JSF core,html和facelets标记库)在xhtml页面中呈现。

  36. JSF可以支持多个face配置文件吗? (Can the JSF support multiple faces configuration files?)

    Yes, any number of faces configuration files can be used but should be declared in the web.xml file as shown below.

    <?xml version="1.0" encoding="UTF-8"?>
    <web-app version="3.1" xmlns="https://xmlns.jcp.org/xml/ns/javaee" 
    	xmlns:xsi="https://www.w3.org/2001/XMLSchema-instance" 
    	xsi:schemaLocation="https://xmlns.jcp.org/xml/ns/javaee 
    	https://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd">
    <context-param>
    	<param-name>javax.faces.CONFIG_FILES</param-name>
    	<param-value>/WEB-INF/faces-config1.xml,/WEB-INF/faces-config2.xml</param-value>
    </context-param>
    </web-app>

    是的,可以使用任意数量的faces配置文件,但应在web.xml文件中声明,如下所示。

  37. Backing Bean和Managed Bean之间有什么区别? (What are the differences between a Backing Bean and Managed Bean?)

    Backing Beans should be defined in request scope whereas managed bean can be defined in request,session or application scopes.Backing bean is referenced by a form whereas a managed bean is registered with JSF and created automatically when needed.

    支持Bean应该在请求范围内定义,而托管Bean可以在请求,会话或应用程序范围内定义。支持bean由表单引用,而托管Bean向JSF注册并在需要时自动创建。

  38. 如何在JSF中显示错误消息? (How to display error messages in JSF?)

    The h:messages tag shows all the error messages at one place corresponding to UI elements. The “for” attribute can be used to represent the field for which error message has to be displayed.

    For a complete example, please read JSF Error Messages Example.

    h:messages标记将所有错误消息显示在与UI元素相对应的位置。 “ for”属性可用于表示必须为其显示错误消息的字段。

    有关完整的示例,请阅读《 JSF错误消息示例》

  39. JSF中的selectOne菜单标签有什么意义? (What is the significance of selectOne menu tag in JSF?)

    The selectOne enables users to select a single value from the list of values. This component can be rendered as a list box, a set of radio buttons or a menu.

    selectOne使用户可以从值列表中选择一个值。 该组件可以呈现为列表框,一组单选按钮或菜单。

  40. 解释立即属性和渲染属性? (Explain immediate and rendered attributes?)

    The immediate attribute if set to true can force validations, events and conversions processed during request phase of the lifecycle. Command component’s immediate attribute indicates what happens when the component gets activated. If the button’s immediate attribute is set to true and associated text field’s immediate attribute set to false then the event is processed without applying the field’s value to the model. In other words the value entered in the field does not even reach the model when the button is clicked but immediately processed in the above scenario.

    The rendered attribute indicates whether a component should be rendered or not in the view page. Rendered attribute can use arithmetic operators and literals with rvalue expression but not lvalue expressions.

    如果将即时属性设置为true,则可以强制在生命周期的请求阶段进行验证,事件和转换。 命令组件的即时属性指示激活该组件时发生的情况。 如果按钮的即时属性设置为true,并且关联文本字段的即时属性设置为false,则将处理该事件,而不将字段的值应用于模型。 换句话说,当单击按钮时在字段中输入的值甚至没有到达模型,但在上述情况下会立即进行处理。

    rendering属性指示是否应在视图页面中呈现组件。 呈现的属性可以使用带有右值表达式的算术运算符和文字,但不能使用左值表达式。

  41. 提到JSF支持的两种绑定方式? (Mention two ways of binding supported by JSF?)

    1. Binding the component’s value to a bean property or other external data source
    2. Binding the component’s instance to a bean property

    1. 将组件的值绑定到bean属性或其他外部数据源
    2. 将组件的实例绑定到bean属性
  42. JSF框架需要哪些配置? (What are required configurations for JSF framework?)

    There are two configuration files namely;

    1. web.xml: This is the general web application configuration file containing the details of deployment. This contains the faces config file responsible for handling the application.
    2. faces-config.xml: allows to configure the application, managed beans, converters, validators, and navigation.

    有两个配置文件:

    1. web.xml:这是包含部署详细信息的常规Web应用程序配置文件。 这包含负责处理应用程序的faces配置文件。
    2. faces-config.xml:允许配置应用程序,托管Bean,转换器,验证器和导航。
  43. 什么是JSF导航规则? (What is JSF Navigation Rule?)

    The rules provided by JSF Framework to describe the view to be shown when a button or link is clicked is called a navigation rule. For complete details, please read JSF Navigation Rules Tutorial.

    JSF Framework提供的描述单击按钮或链接时显示的视图的规则称为导航规则。 有关完整的详细信息,请阅读JSF Navigation Rules Tutorial

  44. JSF转换器标签的作用是什么? (What is the role of JSF converter tags?)

    The convertor tags convert the UI component’s data to object used in a managed bean and vice versa. For example, these tags can convert a text into date object and can validate the format of input as well.

    convertor标记将UI组件的数据转换为托管Bean中使用的对象,反之亦然。 例如,这些标签可以将文本转换为日期对象,也可以验证输入格式。

  45. 列出JSF中数据表标签的好处? (List the benefits of data table tags in JSF?)

    • DataTable can iterate over collection or array of values to display data.
    • DataTable provides attributes to modify its data in easy way

    Read more at JSF Data Table Example.

    • DataTable可以遍历值的集合或值数组以显示数据。
    • DataTable提供了可以轻松修改其数据的属性

    在“ JSF数据表示例”中了解更多信息

  46. 如何在JSF中实现国际化(i18n)? (How to implement internationalization (i18n) in JSF?)

    Internationalization is a mechanism in which status messages, GUI component labels, currency, date are stored outside the source code in resource bundles and retrieved dynamically rather than hardcoding in the program based on the user locale.

    国际化是一种机制,其中状态消息,GUI组件标签,货币,日期存储在资源包中的源代码外部,并动态检索,而不是根据用户区域设置在程序中进行硬编码。

  47. 什么是组件渲染模型? (What is component rendering model?)

    The JavaServer Faces component architecture is designed such that the functionality of the components is defined by the component classes, whereas the actualities of the rendering itself can be defined by a separate renderer called as component rendering model.

    JavaServer Faces组件体系结构的设计使得组件的功能由组件类定义,而渲染本身的实际情况可以由称为组件渲染模型的单独渲染器定义。

  48. 什么是渲染工具包? (What is a render kit?)

    A render kit defines how component classes map to component tags that are appropriate for a particular client.

    渲染工具包定义组件类如何映射到适合特定客户端的组件标签。

  49. 什么是视图对象? (What is view object?)

    A view object is a model object used specifically in the presentation tier but defined outside it. It contains the data that must be displayed in the view layer and the logic to validate user input, handle events, and interact with the business-logic tier.

    视图对象是专门用于表示层但在其外部定义的模型对象。 它包含必须在视图层中显示的数据以及用于验证用户输入,处理事件以及与业务逻辑层进行交互的逻辑。

  50. Bean Scope是什么意思? (What do you mean by Bean Scope?)

    Bean scope is the mechanism of binding the beans and other objects to be available in the different components of a web application.

    Bean作用域是一种将Bean和其他对象绑定为可在Web应用程序的不同组件中使用的机制。

  51. JSF-1和JSF-2有什么区别? (What is the difference between JSF-1 and JSF-2?)

    • JSF1 does not support the usage of annotations but JSF2 supports annotations that makes it far better than JSF1.
    • JSF1 Ajax support was limited, however JSF2 support all the ajax features.
    • JSF1 does not provide Template concepts whereas JSF2 does.
    • JSF1 was first released and API was having a lot of bugs, JSF2 is totally redesigned and can be used as MVC framework in larger applications.

    • JSF1不支持使用注释,但是JSF2支持注释,这使其远胜过JSF1。
    • 对JSF1 Ajax的支持是有限的,但是JSF2支持所有ajax功能。
    • JSF1不提供模板概念,而JSF2提供。
    • JSF1最初发布并且API存在很多错误,JSF2完全经过了重新设计,可以在较大的应用程序中用作MVC框架。
  52. 我们可以拥有没有faces-config.xml的JSF应用程序吗? (Can we have a JSF application without faces-config.xml?)

    In JSF 1.0 faces-config.xml is mandatory whereas JSF 2.0 supports annotations which does not need faces-config.xml.

    在JSF 1.0中,faces-config.xml是必需的,而JSF 2.0支持不需要faces-config.xml的注释。

  53. JSF应用程序有哪些最佳实践? (What are some of the best practices for JSF application?)

    The best practices for JSF application includes

    • Avoid using JSF components for static value.
    • Short component Id
    • Avoid component bindings
    • Facelets for dynamic includes

    JSF应用程序的最佳实践包括

    • 避免将JSF组件用于静态值。
    • 短ID
    • 避免组件绑定
    • 动态包含的方面
  54. 您如何将JSF与Spring框架进行比较? (How do you compare JSF with Spring Framework?)

    Spring uses Inversion of Control and Dependency Injection whereas JSF does not.

    Spring has built in modules for Login-Logout available for ready integration whereas in JSF we have to write the login feature manually.

    Since Spring uses dependency injection the user based pojo classes can be injected with springs whereas JSF is tightly coupled with Java EE architecture.

    Spring使用控制反转和依赖注入,而JSF不使用。

    Spring内置了用于Login-Logout的模块,可用于集成,而在JSF中,我们必须手动编写登录功能。

    由于Spring使用依赖注入,因此可以向用户注入基于用户的pojo类,而JSF与Java EE体系结构紧密结合。

  55. 为什么JSF尽管不如Spring MVC那样像MVC框架那样流行? (Why JSF is not so popular as MVC framework like Spring MVC, even though its older?)

    Some of the reasons I could thought of are;

    • There are many implementations of JSF like Mojarra, Primefaces, Richfaces etc which makes it difficult for the user to comprehend learn and adapt to whereas Spring MVC has only one implementation maintained by a Single group of developers which avoids confusion.
    • Spring has got great integration with data management through standalone or ORM frameworks out of the box which is lacking in JSF based implementation.
    • DI and IOC design patterns makes it very easy to integrate existing legacy applications with new Spring based applications whereas JSF does not have such kind of capabilities.
    • JSF is a component based framework whereas Spring is a Request-Response based framework and hence easy to understand and relates closely to MVC, Struts2 and other similar frameworks

    我能想到的一些原因是;

    • JSF有许多实现,例如Mojarra,Primefaces,Richfaces等,这使用户难以理解和适应,而Spring MVC仅由一个开发人员小组维护了一个实现,从而避免了混乱。
    • 通过独立的ORM框架,Spring已与数据管理实现了很好的集成,这是基于JSF的实现所没有的。
    • DI和IOC设计模式使将现有的旧版应用程序与基于Spring的新应用程序集成变得非常容易,而JSF没有这种功能。
    • JSF是基于组件的框架,而Spring是基于请求-响应的框架,因此易于理解,并且与MVC,Struts2和其他类似框架紧密相关
  56. 我们可以将JSF与其他流行的框架(例如Spring,Hibernate等)集成吗? (Can we integrate JSF with other popular frameworks such as Spring, Hibernate etc?)

    Yes, we can integrate JSF framework with Spring, Hibernate, JDBC etc. Since JSF is more focused on view components, we can utilize it for user interface and other frameworks as backend server side integration and ORM tools. Some of the posts you should look for integrations are;

    是的,我们可以将JSF框架与Spring,Hibernate,JDBC等集成。由于JSF更侧重于视图组件,因此我们可以将其用于用户界面和其他框架,作为后端服务器端集成和ORM工具。 您应该寻找集成的一些职位是:

That’s all for JSF Interview Questions and Answers, I hope they will help you in interviews for JSF related questions.

这就是JSF面试问题和答案的全部内容,希望它们能在与JSF相关的问题的面试中为您提供帮助。

翻译自: https://www.journaldev.com/7261/jsf-interview-questions-and-answers

jsf面试题

  • 3
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值