Win a copy of Java Concurrency Live Lessons this week in the Threads forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Tabview and inserting pages  RSS feed

 
jhon masco
Ranch Hand
Posts: 98
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HI, I create some views from entity classes with the netbeans wizard. I create these inside a folder structure like this:
(i am using Primefaces 5.2)


if open list.xhtml directly it work fine, but in terrytory.xhtml i have a tabview and i need to show list.xhtml inside one of the tabs but i getting this error :

Cannot find component for expression ":PaisCreateForm" referenced from territory:j_idt43:PaisListForm:datalist:createButton".

PaisCreatForm is the ID of my form in list.xhtml What is happening??? i tried putting territory.xhtml inside country folder but i get the same error.

Here my list.xhtml and territory.xhtml codes:

TERRITORY.XHTML



LIST.XHTML


Please what is happening?
Thank you
 
Tim Holloway
Bartender
Posts: 18531
61
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, I'm not sure about you main problem, but I see some secondary issues that indicate that you need to gain some more basic knowledge.

First of all, JSF backing beans are not Controllers. In JSF, the developer does not create the Controllers, only the View Templates and Models. The Controllers are already all written for you and are part of JSF itself. I've heard rumours that NetBeans may have a "wizard" that doesn't know that when it names things, which is yet another reason to be suspicious of letting IDEs write code for you.

Secondly, you're using action Listeners instead of (POJO) action methods. That means that you probably learned from some very obsolete documentation. There is a still use for action listeners in JSF, but it's so rare I cannot recall a single app I've done over the last decade that used them.

Third, by putting your tabview in a form then source-including a tile that also contains a form, you've violated a basic restriction of HTML. Not just JSF, but HTML itself. No HTML form may contain another HTML form. You also should add an ID to the tabView control. It's a Naming Container control and a generated ID (j_idt43) was created. This id is not constant or predicatable, which is why it's better to provide an explicit ID.

You also have a commented-out IFRAME directive. You might as well remove it. JSF and frames do not play well together.

Most likely PrimeFaces is unhappy that you defined a form inside another form. However, you should verify that you're using the right "ui:" directives so that only the intended elements get included by the ui:include. There are several different directives for facelet sub-view declaration and I can myself never remember which does what. I usually end up having to go back and read the manual.
 
jhon masco
Ranch Hand
Posts: 98
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Tim, Thanks for quick reply.
Yes i dont have many experience in JSF also i forget to say that i am using JPA. Netbeans have a wizard for JPA that generate "model" , "beans", "controllers" and views , i like use it because i save a lot of time.
Anyway i tried deleting the extra form from one of the view but nothing happen, also changed the actiolistener for action and the same thing.
I definitively will begin rewriting the code again but without wizard then i could to have more control and see specifically where the mistakes are.
Thank so much again.
 
Tim Holloway
Bartender
Posts: 18531
61
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I recently came across an acronym that fits JSF/JPA. It's "MVVMC", I believe, although more precisely it should be "MVMVC", meaning Model-View, Model, View, Controller.

A JPA Data Model can be used as part of a JSF View Model, but it doesn't have to be.

A lot of people don't realize that. The ORM Data Model is often not a good fit as a UI Model. A classic example of that is that many ORMs have character or numeric "true/false" values, since some DBMS's don't support boolean primitives. But the JSF checkbox control only works with true Java boolean objects and the JSF converter mechanism cannot fill the difference. Using a separate JSF UI Model object as a fa├žade, however, can remedy that.

The "controller" in ORMs, as I understand it, would be the DAO and Service classes. At least, they fit the general description for a Controller, which is a service that copies data between Model and View and back again. The methods in JSF backing beans do not do that because the actual Model update and View update processes are stages in the JSF lifecycle that are entirely run by JSF itself without using any user-written code.
 
jhon masco
Ranch Hand
Posts: 98
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Again Tim.
I solve the problem but in a diferent way.
First all: I used the netbeans wizard again but this time i just generate the
"Model class" (model in JPA and Netbeans is map the database table for be use with JPA), after that the
"Facade class" (it is something like DAO - the conection to the database)
Then i create by myself the controller (the wizard can do it but i decided do it myself) , then when i was building the view and i put the page in tabview i saw again the same mistakes Cannot find component for expression etc etc but this time i was able to manage these thanks you before explanations about forms. But...when finally the appllication run the app ,the tabview specifically the tab containing the page dont show me nothing!!! Thats was frustrating for me!
Tired of this situation i decided the make the Tabview with Bootstrap NavBar and put my page inside it, it work fine for me! Sincerely i would want be able to use primefaces tab although i am not sure if with bootstrap will be much better for me.

Thanks so much!
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!