Fred Maurice

Greenhorn
+ Follow
since Feb 22, 2019
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Fred Maurice

Tim Holloway wrote:I think one of the problems here is that neither "trainingAlterView" nor "enrollmentView" are actually Views. The naming that the Primefaces examples used was pure sloppiness. And while I'm ranting - here's looking at you NetBeans: backing beans aren't Controllers, either!

A backing bean is a Model. In JSF, the xhtml is a View Template, used by the JSF renderer to construct the actual View (html) for the client. You don't write Controllers at all - they're all pre-supplied as part of JSF and its tag libraries (including PrimeFaces).

It is perfectly proper in JSF for a View Template to reference more than one Model (backing bean). And, for that matter, it is perfectly proper to inject one backing bean as a Managed Property into another backing bean. The only restrictions there are that you observe the scope of the objects in question. If you construct a bean in View Scope, for example, moving to a different View causes that bean to be destroyed. You cannot injected narrower scope objects into broader scoped objects. For example, injecting a Session Scope bean into a Request Scope bean is OK (although, as I say often, Request Scope Is Almost Useless), but the reverse - injecting a Request Scope Bean into a Session Scope bean is not.

So an action method in trainingView could talk to an enrollmentView bean directly, as long as the enrollmentView has been injected as a Managed Property into the trainingView.



I thought ManagedProperty was deprecated? See https://stackoverflow.com/a/4347707/6168454

I'm just so damn confused. Even if I correctly got the EnrollmentView to talk to the trainingAlterView, how would I alter the XHTML/view to reflect it?

2 weeks ago
JSF

Mano Ag wrote:Hi,

I think it should not be that difficult.

It may be the simplest question but, do you have a property to connect your view to ?
Once you have that the rest should be easy.

Do you have an explicit or inherited "course"  property in your backing bean?

(by backing bean I mean POJO or Managed Bean or whatever people chooses to call it...
by property I mean a private variable with  its corresponding getter/setter in a class that
uses the @Named and possibly the @ManagedBean and @Serializable annotations)



So here's the thing.  I'm wondering if "itemValue" is the missing link here. My code:



The issue is, the class that needs to access that value is trainingAlterView, not enrollmentView.  And it needs to be whatever they selected, with all information intact (a CornerstoneCourse object). I was thinking of doing something like adding a "course" property in trainingAlterView and the appropriate getters/setters, and then doing



But that didn't seem to work.  I know I'm missing some fundamental JSF "thing" and it just isn't clicking for me. Any input?
2 weeks ago
JSF

Tim Holloway wrote:Well, I admit I have trouble envisioning just what you're trying to present. It appears to be a course catalog with detail lines about courses. But why that would require an auto-complete escapes me. Most catalogs sub-divide their course offerings into departments, programs, or other sorts of categories and usually those divisions are granular enough that you can display them all in a single window and simply click-to-pick.



It is so managers at my company can sign up their employees for internal courses.  Once selected from the list, they can add that into a "class request" database.  The autocomplete makes it easy to quickly type in a course and find it in the catalog.

So let's say I added a "course" property in my backing bean.  I don't get how to associate/connect that in the View/frontend...
2 weeks ago
JSF

Mano Ag wrote:Hi,

I think it should not be that difficult.

It may be the simplest question but, do you have a property to connect your view to ?
Once you have that the rest should be easy.

Do you have an explicit or inherited "course"  property in your backing bean?

(by backing bean I mean POJO or Managed Bean or whatever people chooses to call it...
by property I mean a private variable with  its corresponding getter/setter in a class that
uses the @Named and possibly the @ManagedBean and @Serializable annotations)



I don't have that. I guess I'm just not sure how to correctly set it up.
2 weeks ago
JSF
The autoComplete actually helps since it forces you to pick values it returns from the database.  You can't edit the value after you click on a selection that autoComplete suggests.  It's actually pretty slick.  Anyway, I am not feeling too good about this project. I'm going to try tinkering a bit more.   I just seriously don't understand why it is so complex so pass a value around.


2 weeks ago
JSF
Thanks again Tim.  


The p:autoComplete I believe does return a string, so how would you approach this in that case? Here's the documentation: https://www.primefaces.org/showcase/ui/input/autoComplete.xhtml

If I can just extract the ENumber property I can use a method I already have to do a db lookup with it.

I'm trying not to get  frustrated but this is far more complex that I would have imagined it to be. Your help is greatly appreciated.
2 weeks ago
JSF
Tim,

Thanks again.  This helps.  I feel like I'm getting closer. I believe I implemented what you suggested and it compiled fine, but when it comes time to submit the form, all of the values were NULL.

For the DataModel method, I did this:



And then in the addTrainingReques method:



I still don't fully understand how it "knows" what p:autoComplete item (course) they picked based on this code, but I'll take your word for it that the MVC has it all figured out.  However, this didn't work.

What I did above is basically first use this DataModel suggestetion to get the CornerstoneCourse object and then get the LearningObject I need by using a method that was already written to search by ENumber (unique course IDs). This all compiles fine and I was excited to see it work, but running in debug mode and setting breakpoints in Eclipse it seems everything is null.  Any other ideas or do you need anymore detail from me?

2 weeks ago
JSF
Thanks Tim.  I've no doubt I'm not doing things per "best practices".  In fact I'm not too up to speed on proper MVC architecture, which is likely part of the problem.

complete objects are not transferred in that case, just ordered collections of strings.



That sounds reasonable.  Again I'm just not sure how to pass in all of these property strings into this method when I click the command button:



I'm going to need to pass all (or at least some of these properties) to the trainingAlterView:



What is the most straightforward way to approach this?
2 weeks ago
JSF

Mano Ag wrote:Hi Fred,

Did you try the "Primefaces Showcase" for info? https://www.primefaces.org/showcase/

It might have what you need.



Hi Mano,

Thanks.  I have looked at that documentation - unfortunately it's not up to date - on their p:autoComplete page, they are using deprecated features such as "@ManagedBean".

Do you have any idea how to do what I'm describing? Frankly, I don't think it should be too difficult.
2 weeks ago
JSF
Hi all,

Very much new to JSF and trying to figure out the "JSF way of doing things".  I have what I believe to be a fairly simple issue.

First off, my set up:


* WildFly 8.1.0.Final "Kenny"
* Mojarra 2.2.6-jbossorg-4
* PrimeFaces 6.1
* PrimeFaces Extensions 6.1


I'm simply trying to pass data from an XHTML (JSF) page, to the backing bean/view. I have a p:autoComplete that looks like this:

class_request_system.xhtml



And then on the backing bean/view, I'd like to not only get the value of the autoComplete, which ends up being the title of course, but every single property listed above - course.code, course.title, course.type, etc. Everything I've read thus far talks about using the value to associate the value with the backing bean, however, the value is 'preoccupied' with the #{enrollmentView.courseList}.  So I've looked at using "var" and "itemValue" but I'm not sure that's the right path either.

Here's where I'm trying to get the above data:


TrainingAlterView.java


But then it gets even more confusing, since later on in that method, there's a huge switch statement that depends on methods that are usually in a typical LearningObject variable which are associated with getitng information about the course but also getting information about the person taking the course:




I don't understand how to pass the values between pages but, even more so, creating that object again which will have all of the methods that it will need to perform this approval logic that works elsewhere in the application for a removeTrainingRequest since it's tapping into an already existing LearningObject, not creating one from scratch. Maybe there's a way to pass an Object between pages - like the entire "course" object above? - that would be ideal.


I would greatly appreciate any help.  Any tutorial or stackoverflow I read inevitably isn't the exact same situation I'm in and typically isn't too applicable. Thanks in advance.
2 weeks ago
JSF
Hi folks,

I am trying to use the following widget from the PrimeFaces showcase: https://www.primefaces.org/showcase/ui/input/multiSelectListbox.xhtml

My setup is as follows:

* WildFly 8.1.0.Final "Kenny"
* Mojarra 2.2.6-jbossorg-4
* PrimeFaces 6.1
* PrimeFaces Extensions 6.1

I literally copied and pasted the exact multiSelectListbox.xhtml and MultiSelectView.java code, and the resulting page does not have the functionality portayed in the showcase page - it just does nothing. And when "Save" is clicked, I get:



I am wondering if this is something as simple as my version of PrimeFaces doesn't support this widget, something with my configuration, etc?  Because I don't believe the code is the problem.

Thanks for any help in advance. Btw, this forum looks great. Reminds me of the "old internet"...
1 month ago