jsf tree组件

JSF Form component is a collection of fields along with the data and submit functionality to be sent to the model implementing the business scenario.

JSF Form组件是字段以及数据和提交功能的集合,这些字段将被发送到实现业务场景的模型。

JSF表格 (JSF Form)

To use the form in your JSF page include the following namespace;

要在JSF页面中使用该表单,请包含以下名称空间:

xmlns:h="https://java.sun.com/jsf/html"

xmlns:h="https://java.sun.com/jsf/html"

Some of the important form tag attributes are;

一些重要的表单标签属性是:

  1. id: This is the unique identifier used to identify a component.id:这是用于标识组件的唯一标识符。
  2. onclick: invokes the javascript function to be called when a button is clicked next to an element.onclick:当单击元素旁边的按钮时,调用要调用的javascript函数。
  3. onsubmit: The javascript function to be called on click of form by a submit button.onsubmit:通过提交按钮单击表单时要调用的javascript函数。
  4. onreset: Javascript to be invoked on the reset of the elements in a form.onreset:重置表单元素时要调用的Javascript。
  5. rendered: flag indicating whether a component should be rendered or still processed.渲染:标志,指示是否应渲染或仍在处理组件。
  6. binding: value of the expression linked to a property in a backing bean.绑定:链接到支持bean中的属性的表达式的值。
  7. lang: the language used by the components in the form.lang:表单中组件使用的语言。
  8. target: Name of the frame where the resource retrieved is to be displayed.target:将在其中显示检索到的资源的框架的名称。
  9. accept: the contents list that the form can handle.accept:表单可以处理的内容列表。
  10. ondblclick: Javascript code to be executed when the mouse is double clicked over a field in a form.ondblclick:在表单的字段上双击鼠标时要执行的Javascript代码。
  11. onmouseup: Javascript code to be executed when the mouse button is released over a component.onmouseup:在组件上释放鼠标按钮时要执行的Javascript代码。
  12. onmousedown: Javascript code to be executed when the mouse pointer is clicked down over this element.onmousedown:在该元素上单击鼠标指针时要执行的Javascript代码。
  13. acceptCharSet: defines the list of character encoding that the form will accept.acceptCharSet:定义表单将接受的字符编码列表。
  14. style: The CSS style definitions that can be applied for the formstyle:可应用于表单CSS样式定义
  15. prependId: flag that indicates whether id should be prepended to the formprependId:标志,指示是否应在表单之前添加id
  16. dir: Overrides default text functionality for this component.dir:覆盖此组件的默认文本功能。
  17. title: A title for an element of the form used as tooltip.title:用作工具提示的表单元素的标题。

JSF表单示例 (JSF Form Example)

Consider an example to demonstrate the usage of the JSF form. A minimalistic form contains at least some text fields, labels and a submit button to generate a post request. This example demonstrates a minimal JSF form page.

考虑一个示例,以演示JSF表单的用法。 简约形式至少包含一些文本字段,标签和一个提交按钮以生成发布请求。 本示例演示了一个最小的JSF表单页面。

Create a page called cardetails.xhtml as shown below.

创建一个名为cardetails.xhtml的页面,如下所示。

<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="https://www.w3.org/1999/xhtml"xmlns:h="https://java.sun.com/jsf/html">
<h:head><title>Adding a Form</title>
</h:head>
<h:body><h:form><h3>Adding Form Components</h3><h:panelGrid columns="3"><h:outputLabel for="cname">Car Name:</h:outputLabel><h:inputText value="#{car.cname}" id="cname"></h:inputText><br><br><h:outputLabel for="Id">Car Id:</h:outputLabel><h:inputText value="#{car.id}"></h:inputText><br><br><h:outputLabel for="color">Color:</h:outputLabel><h:inputText value="#{car.color}"></h:inputText><br><br><h:outputLabel for="model">Model:</h:outputLabel><h:inputText value="#{car.model}"></h:inputText><br><br><h:outputLabel for="regno">Registration Number:</h:outputLabel><h:inputText value="#{car.regno}"></h:inputText><br><br><h:commandButton action="viewdetails" value="Submit"></h:commandButton></h:panelGrid></h:form>
</h:body>
</html>

In the JSF page above, we declared a <h:form> tag that contains the fields – name, id, model, color and registration number pertaining to the car object. All these fields together constitute a Car form wherein a user can enter the details and click the submit button to post the details.

在上面的JSF页面中,我们声明了一个<h:form>标记,其中包含与汽车对象有关的字段-名称,id,型号,颜色和注册号。 所有这些字段一起构成了Car表单,用户可以在其中输入详细信息,然后单击“提交”按钮以发布详细信息。

Upon click of the form submit button, viewdetails.xhtml page is called that prints the data entered by the user.

单击表单提交按钮后,将调用viewdetails.xhtml页面, viewdetails.xhtml页面将打印用户输入的数据。

Let’s now create the viewdetails.xhtml page that displays all the car details entered by the user.

现在,让我们创建viewdetails.xhtml页面,该页面显示用户输入的所有汽车详细信息。

<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="https://www.w3.org/1999/xhtml"xmlns:h="https://java.sun.com/jsf/html">
<h:head><title>Car Details</title>
</h:head>
<h:body>Car Id:#{car.id}<br><br>Car Name:#{car.cname}<br><br>Car color:#{car.color}<br><br>Car Model:#{car.model}<br><br>Car Registration Number:#{car.regno}</h:body>
</html>

This view page fetches all the details from the Car bean through getter and setter methods.

该视图页面通过getter和setter方法从Car bean获取所有详细信息。

Below is the code for Car managed bean.

下面是Car 管理的bean的代码。

package com.journaldev.jsf.beans;import java.io.Serializable;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;@ManagedBean
@SessionScoped
public class Car implements Serializable {private static final long serialVersionUID = 1715935052239888761L;private String cname;private String color;private String Id;private String model;private String regno;public Car() {}public Car(String cname, String color, String Id, String model, String regno) {this.cname = cname;this.color = color;this.Id = Id;this.model = model;this.regno = regno;}public String getColor() {return color;}public void setColor(String color) {this.color = color;}public String getCname() {System.out.println("car name is" + cname);return cname;}public void setCname(String cname) {this.cname = cname;}public String getRegno() {return regno;}public void setRegno(String regno) {this.regno = regno;}public String getModel() {return model;}public void setModel(String model) {this.model = model;}public String getId() {return Id;}public void setId(String Id) {this.Id = Id;}}

The Car class contains the getter and setter methods for all the fields.The @ManagedBean annotation indicates that the car is a managed bean and @SessionScoped indicates that the bean is valid for the session.

Car类包含所有字段的getter和setter方法。@ @ManagedBean批注指示car是托管bean, @SessionScoped指示bean对会话有效。

Below image shows the final project structure of the project.

下图显示了该项目的最终项目结构。

JSF表单示例测试 (JSF Form Example Test)

Just build the project and run the application, you should get below response in the browser.

只需构建项目并运行应用程序,您应该在浏览器中得到以下响应。

That’s all for the JSF form example and the interaction between the managed beans. You can download final project from below link and play around with it to learn more.

这就是JSF表单示例以及托管Bean之间的交互的全部内容。 您可以从下面的链接下载最终项目并进行试用以了解更多信息。

Download JSF Form Components Project下载JSF表单组件项目

翻译自: https://www.journaldev.com/6950/jsf-form-components-example-tutorial

jsf tree组件

jsf tree组件_JSF表单组件示例教程相关推荐

  1. jsf tree组件_JSF UI组件标签属性示例教程

    jsf tree组件 JSF provides a wide variety of ui component tags along with a long range of attributes. T ...

  2. jsf tree组件_JSF文本组件–标签,文本字段,文本区域和密码

    jsf tree组件 The Text components allows the user to add, view and edit data in a form of a web applica ...

  3. jsf tree组件_JSF:在传统组件和时尚性能杀手之间进行选择

    jsf tree组件 这篇博客文章起源于一个大型Web应用程序中的性能问题. 每个人都优化Java代码,但似乎没有人尝试优化JavaScript代码. 奇怪,因为在客户端有很多改进的空间. 我会说,甚 ...

  4. jsf tree组件_JSF和“立即”属性–命令组件

    jsf tree组件 JSF中的即时属性通常被误解. 如果您不相信我,请查看Stack Overflow . 造成混淆的部分原因可能是由于输入(即<h:inputText />)和命令(即 ...

  5. 移动端通用元件库+app通用元件库+数据展示+操作反馈+通用模板+数据录入+列表页+表单页+详情页+通用版布局+移动端手机模板+业务组件+反馈组件+展示组件+表单组件+导航组件

    移动端通用元件库+app通用元件库+数据展示+操作反馈+通用模板+数据录入+列表页+表单页+详情页+通用版布局+移动端手机模板+业务组件+反馈组件+展示组件+表单组件+导航组件 原型展示及下载地址:h ...

  6. 表单引擎之表单组件详细说明

    简介 表单组件是表单引擎的核心,下面将对常用表单组件进行详细的说明. 文档约定 字符"●"标识"是". 字符"○"表示"否&quo ...

  7. 微信小程序学习之路——表单组件(一)

    radio组件 1.radio-group 在小程序中<radio/>不能单独使用,同一组<radio/>需要包含在一个<radio group/>中,这样才能形成 ...

  8. Vue form-create的基本使用 和 自定义表单组件的数据通迅

    前言 由于之前有个Web项目,大部分都是表单,而且这些表单是通过请求后端接口返回的数据,动态生成对应的DOM(表单类型),以及表单的初始数据渲染,和修改表单后的数据提交. 根据以上项目情况,所以这次就 ...

  9. 微信小程序 - 基础 - 003 - WEUI - 基本表单组件 - form - 页面数据提交和获取 - 01

    前言:form作为数据提交的重要控件,历来在前端设计中非常重要.微信给出了完整的form的例子.参考了一些微信设计的书籍,大多数都是copy 粘贴了例子的东西.... 其实微信的例子给的比较充分了: ...

最新文章

  1. Spring源码解析 - AbstractBeanFactory 实现接口与父类分析
  2. 想在小程序上“飙车”?特斯拉小程序做到了
  3. splice方法_[7000字]JavaScript数组所有方法基础总结
  4. Linux 环境下vs2015 qt,QT5.8.0+MSVC2015安装以及环境配置(不需要安装VS2015)
  5. mysql去除空格的函数_MySQL字符串尾部空格匹配的问题
  6. 网络流--最大流--Dinic模板矩阵版(当前弧优化+非当前弧优化)
  7. vim 编程常用的指令和快捷键
  8. 基于单片机步进电机ppt答辩_基于单片机的步进电机式汽车仪表的设计(含电路原理图,程序)...
  9. 讲讲你理解的服务治理
  10. Apple Watch再立功!67岁男子意外摔倒后得救
  11. android studio release error INSTALL_FAILED_INSUFFICIENT_STORAGE
  12. vscode编写php好用吗,vscode可以编写php吗
  13. python线程池超过最大数量_讨论一下Python线程池大小设置?
  14. #define 和 #typedef , const的区别
  15. 苹果手机如何找回id密码_苹果手机丢失24天后成功找回
  16. 魔众微信管理系统 v1.0.0 更简单可用的微信公众号管理系统
  17. Pr 入门教程了解基本校正选项
  18. 让2010成为我的新纪元
  19. 基于 FFMPEG 的像素格式变换(swscale,致敬雷霄骅)
  20. 前端面试总结 -- 网络基础之 HTTP 和 HTTPS

热门文章

  1. 【转】各种字符串算法大总结
  2. nodejs+express开发blog(2)
  3. Time complexity analysis of algorithms
  4. POJ - 1008 Maya Calendar
  5. Oracle提供的自治事务记录日志的方法
  6. [转载] pythonjson构建二维数组_python二维键值数组生成转json的例子
  7. 前端组件化思想与实践
  8. 图片的色彩空间转换、简单色彩跟踪与通道分离、合并(三)
  9. leetcode - 4. Median of Two Sorted Arrays
  10. ExtJS视频学习笔记