stephanrauh / AngularFaces

AngularFaces is a JSF library making it easy to integrate AngularJS code.
https://www.angularfaces.net
Apache License 2.0
90 stars 39 forks source link

ng* pass through attributes don't seem to be working #68

Closed deronrspencer closed 8 years ago

deronrspencer commented 8 years ago

I have a basic sign up page with AngularFaces, BootsFaces and Primefaces in a jsf application. I am trying to use the ng-show/hide attributes to manipulate visibility of page elements based on values in others however even with simplest form (ng-show="false") this is not working. All elements are still being rendered. Auto labels are working. My setup process was to edit pom.xml to add AngularFaces dependencies, edit web.xml to add context-param as instructed and then try ng-show in page. Adding ng-app attribute to html element does not help.

deronrspencer commented 8 years ago

Is this working for anyone else? Would want a working case to help in troubleshooting my setup

stephanrauh commented 8 years ago

First of all, I'm sorry for answering late. I suppose you added the AngularTagDecorator to the web.xml? If you, you might try to set a breakpoint in line 322. Is the if block ever reached? It is responsible for making the ng-show/hide attribute a pass-through attribute.

            if (a.getLocalName().startsWith("ng-")) {
                // make AngularJS attributes pass-through attributes
                modifiedAttribute = TagAttributeUtilities.createTagAttribute(a.getLocation(), PASS_THROUGH_NAMESPACE,
                        a.getLocalName(), a.getLocalName(), modifiedValue);
                hasChanges = true;
            } ```
deronrspencer commented 8 years ago

It does hit that line. Tracing it through further eventually get's me to generateTagIfNecessary and it hits the else branch of the If statement there. I'm mentioning this because I notice the first 2 conditions call generatePuiHtml which in turn has a reference to the constant PASS_THROUGH_NAMESPACE, while the else doesn't. Not sure if this could be it as I am really not an expert here.

stephanrauh commented 8 years ago

You might be up to something. BTW, thanks for taking the time and debugging! I guess this is the else path you're referring to?

return new Tag(tag.getLocation(), tag.getNamespace(), tag.getLocalName(), tag.getQName(),
                        modifiedAttributes);

In theory, this should work, because the namespace has been encoded in the modifiedAttributes attribute, but maybe this is a wrong assumption. It may also depend on your server. Which application server do you use? And which libraries? In particular, do you use MyFaces or Mojarra?

deronrspencer commented 8 years ago

Yep,that's the else line. I'm using myfaces on Websphere Application Server Liberty profile 8.5. I also have Bootsfaces and Primefaces in there.

stephanrauh commented 8 years ago

Using BootsFaces is always a good idea :).

stephanrauh commented 8 years ago

Maybe it's a Websphere problem. A couple of days ago, I've learned that Websphere does a couple of thing differently from, say, Tomcat. Maybe that's the same story here. Currently, I don't have a Websphere server at hand, but maybe I can have a glance at it this week-end.

Until then, I suggest you work-around the problem by using JSF 2.2 pass-through attributes. I've designed AngularFaces to be a more developer-friendly alternative, but at least the verbose standard-approach works :).

deronrspencer commented 8 years ago

OK. Will try that. From what i gather, Tomcat is a few pieces shy of a full J2EE app server and Liberty has the pros of loading only the components you need to support your app so you don't have to roll out a full stack J2EE compliant server to run an app that only needs a subset of the features. The con seems to be that you get some quirky behavior at times from IBM stuff. Any recommendations for a good and lightweight J2EE app server?

stephanrauh commented 8 years ago

TomEE? Wildfly? But truth to tell, as far as I know there's nothing wrong with WAS Liberty. Quite the contrary, I like the OSGI concept it's built upon. It's just that these innovative concepts make it difficult to provide frameworks compatible to every application server :).

deronrspencer commented 8 years ago

I looked up doing the JSF pass through. Getting the following error.

Can't find facelet tag library for uri http://java.sun.com/jsf/passthrough

stephanrauh commented 8 years ago

I've been thinking all day about this. I believe something's wrong with out project setup. I've tried to investigate which version of JSF IBM WAS liberty 8.5 supports. By the look of it, it's JSF 2.0 - but not JSF 2.2. That's why AngularFaces doesn't work properly. See http://www-01.ibm.com/support/knowledgecenter/SSD28V_8.5.5/com.ibm.websphere.wlp.core.doc/ae/twlp_config_jsf22.html on how to update to JSF 2.2.

deronrspencer commented 8 years ago

I'm using the webProfile-7.0 feature which includes jsf 2.2. See link below.

https://www-01.ibm.com/support/knowledgecenter/SSEQTP_8.5.5/com.ibm.websphere.wlp.doc/ae/rwlp_feature_webProfile-7.0.html

stephanrauh commented 8 years ago

OK. I've installed a IBM WAS liberty server in my local copy of Eclipse. Would you mind to upload your project (i.e. on GitHub) or send me a zip file of your project so I can easily reproduce your issue?

Thanks in advance Stephan

deronrspencer commented 8 years ago

Can send you a zip file. Let me know where to send it.

Thanks

stephanrauh commented 8 years ago

Hi Globalyst,

Please send it to webmaster1 at beyondjava.de (the " at " being an @ - I don't like spam :) ).

Cheers Stephan

Am 19.02.2016 um 23:49 schrieb theglobalyst notifications@github.com:

Can send you a zip file. Let me know where to send it.

Thanks

— Reply to this email directly or view it on GitHub.

stephanrauh commented 8 years ago

As it turns out, the error was caused by a missing ng-controller declaration. I'll add the need to improve the documentation into the backlog of the project, and consider the ticket closed.