简体   繁体   English

如何基于java框架(JSF)中URL的json响应生成动态表单?

[英]How to generate dynamic form based on my json response from URL in java framework (JSF)?

I want to create dynamic form based on my json data in my browser,I know this is possible from using some javascript library like inputex etc but I am not expert in using javascript,I have made application using jsf 2.0 , I wanted some solution in Java, some thing like android , where we can easily create any type of UI dynamically, here is my json from which I need to create form , I can modify this response for any help as this json is also made by me. 我想在浏览器中基于json数据创建动态表单,我知道可以通过使用某些JavaScript库(例如inputex等)来实现,但我不是使用JavaScript的专家,我已经使用jsf 2.0编写了应用程序,我想要一些解决方案Java,例如android之类的东西,我们可以轻松地动态创建任何类型的UI,这是我需要创建表单的json,我可以修改此响应以获取任何帮助,因为该json也是我制作的。

  {
surveyQuestions: [3]
0:  {
choice: [3]
0:  "choice1"
1:  "choice2"
2:  "choice3"
-
date: "2013-10-30T00:00:00+05:30"
q_id: "10"
question: "Question 1?"
questionType: "single_choice"
surveyType: "first_survey"
versionid: "1.1"
}-
1:  {
choice: [5]
0:  "choice0"
1:  "choice1"
2:  "choice2"
3:  "choice3"
4:  "All of Above"
-
date: "2013-10-30T00:00:00+05:30"
q_id: "11"
question: "Question 2?"
questionType: "multiple_choice"
surveyType: "first_survey"
versionid: "1.1"
}-
2:  {
choice: [4]
0:  "choice1"
1:  "choice2"
2:  "choice3"
3:  "choice4"
-
date: "2013-10-30T00:00:00+05:30"
q_id: "12"
question: "Question 3?"
questionType: "single_choice"
surveyType: "first_survey"
versionid: "1.1"
}-
-
}

Instead of using javascript, read that json in your backing bean / controller and work with that. 而不是使用javascript,请在​​您的后备bean /控制器中读取该json并进行处理。

You should transform that json in an appropiate list of objects that you can use in java. 您应该在可以在Java中使用的适当对象列表中转换该json。 If you need a library to work with json in java, look at the answers of this question: https://stackoverflow.com/q/338586/1073063 如果需要使用Java中的json的库,请查看以下问题的答案: https : //stackoverflow.com/q/338586/1073063

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何根据从 JSON 接收到的数据生成动态表单 - How to generate dynamic form based on data received from JSON 如何通过数组映射生成基于api响应的动态表单? - How to map through the array to generate dynamic form based on api response? 如何从动态数量的 URL 获取响应并组合来自所有 URL 的 JSON 响应 - How to get response from a dynamic amount of URL's and combine JSON response from all of them 如何从JSON响应生成React视图 - How to generate React view from JSON response angularjs-如果我的响应在运行时更改结构,如何生成动态页面 - angularjs - how to generate dynamic pages if my response is changing structure at runtime 用于从JSON或类似数据生成/呈现动态HTML表单的JavaScript? - JavaScript to generate/render dynamic HTML form from JSON or similar data? 如何通过Drupal JSON:API响应中的术语关系在Gatsby中创建动态URL? - How to create dynamic URL's in Gatsby from term relationships in Drupal JSON:API response? 如何从 JSON 对象生成 URL? - how to generate a URL from JSON object? 如何基于Javascript中的动态网格大小生成网格坐标? - How to generate my grid coordinates based on a dynamic grid size in Javascript? 如何从 JSON 文件中读取动态 url? - How to read dynamic url from JSON file?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM