Hello,
I would like to ask if it is possible to create HTML pages using pure Java code according to the ideas of this article:
https://dzone.com/articles/creating-jsf-pages-pure-java
If so, whether it is possible to take this approach as a vendor-supported solution and possibly where I can find some guidance.
Best regards,
Pavel
Creating JSF Pages with Pure Java Code
Don't do this. From https://stackoverflow.com/questions/351 ... orm-fields
BalusC wrote:Noted should be that there is absolutely nothing which is only possible in Java (way #2) and impossible in XHTML+XML (way #1). Everything is possible in XHTML+XML as good as in Java. A lot of starters underestimate XHTML+XML (particularly <ui:repeat> and JSTL) in dynamically creating components and incorrectly think that Java would be the "one and only" way, while that generally only ends up in brittle and confusing code.
-
- Posts: 4
- Joined: 14 Mar 2019, 11:58
Here are some reasons for using the Java code:Everything is possible in XHTML+XML as good as in Java
- Java coding is usually faster and type-safe, better refactoring is supported in a NetBeans IDE for example
- The compiler does not recognize typing errors of the XHTML to Java API
- It is difficult to implement a component factory service to provide a graphical component in XHTML (according to some meta-data model for example)
- XHTML technology does not know the simple inheritance of components. A component extended of SelectBooleanCheckbox (for special use) is difficult to use in XHTML for example.
- There are probably more reasons for this.
Pavel
Pavel,
of course, this is natural thought. I started the same many years ago. However, I just learned, that separating presentation and business logic is quite usefull. The second learning was, that XHTML is indeed a shorter and better method to represent the view. You can go through some years of experience but you will finally end up with this insight. There will be some problems that get bigger and bigger using low level API's. So just use the 30 man years of Primefaces that deliver components already optimized with their API (and the implementation is sometimes quite complex!). Of course, you'll use Java but only for lists/graphs of objects, that are traversed via view iterators and methods, that you can apply to them.
Marc
of course, this is natural thought. I started the same many years ago. However, I just learned, that separating presentation and business logic is quite usefull. The second learning was, that XHTML is indeed a shorter and better method to represent the view. You can go through some years of experience but you will finally end up with this insight. There will be some problems that get bigger and bigger using low level API's. So just use the 30 man years of Primefaces that deliver components already optimized with their API (and the implementation is sometimes quite complex!). Of course, you'll use Java but only for lists/graphs of objects, that are traversed via view iterators and methods, that you can apply to them.
Marc
PF 7, WildFly 11, Java EE 7, JDK 8
no need to if you encapsulate what you need in 'wrappers' https://stackoverflow.com/questions/682 ... m-componenpavel.ponec wrote: ↑15 Mar 2019, 10:18Java coding is usually faster and type-safe, better refactoring is supported in a NetBeans IDE for example
When do you make those? EL mismatch with @Named beans and its methods IS recognized in a decent IDEpavel.ponec wrote: ↑15 Mar 2019, 10:18The compiler does not recognize typing errors of the XHTML to Java API
Please provide a concrete example? I've done a complex form solution with a 'sort of' factory and many input types that can be compared with what you describe that works perfectlypavel.ponec wrote: ↑15 Mar 2019, 10:18It is difficult to implement a component factory service to provide a graphical component in XHTML (according to some meta-data model for example)
Why is this needed, example? There are options to override/extend things if required.pavel.ponec wrote: ↑15 Mar 2019, 10:18XHTML technology does not know the simple inheritance of components. A component extended of SelectBooleanCheckbox (for special use) is difficult to use in XHTML for example.
Effectively all you seem to have are arguments of things that you need IF you use java to write components.
-
- Posts: 4
- Joined: 14 Mar 2019, 11:58
It is possible that my view may be influenced by the relatively short experience of JSF, however I have many years of experience with the Apache Wicket component framework where there was no problem separate the presentation layer from business logic in the Java code. Therefore, my question remains the same: can anyone advise me how to try it?separating presentation and business logic is quite usefull.
Regards,
Pavel
-
- Posts: 4
- Joined: 14 Mar 2019, 11:58
Hello Ronald, thank you for a detail response.
I'd like to implement missing customer data adapter into the SelectBooleanCheckbox component for general data type.
For some historical reasons, my project uses Enum instead of Boolean in data model.SelectBooleanCheckbox (for special use) ... Why is this needed?
I'd like to implement missing customer data adapter into the SelectBooleanCheckbox component for general data type.
Imagine that the property of each attribute of a domain object is described by a class containing information:component factory ... Please provide a concrete example?
- the attribute name
- data type
- value validator
- max length of input text field
- form creation: https://hotels.ujorm.org/source?src=org ... able&idx=1
- table creation: https://hotels.ujorm.org/source?src=org ... able&idx=0
You can simply use your logic to create the model with pojos, that are not view components but value objects. This model can be traversed by sequencable view components like p:dataTable, p:TreeTable etc. in the XHTML view. That's it!
Marc
Marc
PF 7, WildFly 11, Java EE 7, JDK 8
Besides https://www.primefaces.org/showcase-ext ... naForm.jsf being available
And
No it is not... See the link I already posted. https://stackoverflow.com/questions/351 ... orm-fields. You can wrap things even in a custom component/tag/...pavel.ponec wrote: ↑18 Mar 2019, 10:09I'm afraid that such a solution is very difficult to implement using XHTML of JSF.
And
The second sentence this is still hard to understand.pavel.ponec wrote: ↑18 Mar 2019, 10:09For some historical reasons, my project uses Enum instead of Boolean in data model.SelectBooleanCheckbox (for special use) ... Why is this needed?
I'd like to implement missing customer data adapter into the SelectBooleanCheckbox component for general data type.
-
- Information
-
Who is online
Users browsing this forum: No registered users and 51 guests