Omnifaces extensionless URLs and h:link - jsf-2.2

According to http://showcase.omnifaces.org/facesviews/ExtensionlessURLs by default, all URLs generated by ViewHandler.getActionURL(FacesContext, String), which is used by among others
<h:form>, <h:link>, <h:button>
and all extended tags, will also be extensionless.
I try using this by putting Facelets source files into /WEB-INF/faces-views directory.
I typed /context/entries in the browser and I got the page in /WEB-INF/faces-views/entries.xhtml. But when I used this in my facelet page:
<h:link outcome="entries">Entries</h:link>
The url resulted is /context/WEB-INF/faces-views/entries.xhtml which is not the desirable result. What went wrong?
I am using Mojara 2.2.12 and Omnifaces 2.6.9 and my faces servlet mapping is *.jsf.

There was a small mistake in FacesViews of specifically 2.6.9 which is fixed in 2.7-SNAPSHOT. While working on getting FacesViews to support folders with periods in names such as /foo.bar/baz, I have accidentally committed a part of the fix into 3.x only instead of into 2.x. That explains why it works just fine in 3.1, as demonstrated by the "viewsdemo" showcase. My mistake, this just proves again that I'm a human and not a machine.
There are a few options to get around this:
Downgrade to 2.6.8.
Or, migrate to 3.1.
Or, keep 2.6.9 and use the "Minimal configuration" approach of a single web.xml context parameter instead of "Zero configuration" approach of placing files in /WEB-INF/faces-views.

BalusC is right, switching to version 2.6.8 solves the problem. The credit is BalusC's as always, but he has too much credit so I think he wouldn't mind that I posted an answer myself, just don't want to bother him.
Change the servlet mapping to *.xhtml also solves the problem. With all due respect, Xtreme Biker: a bug is a bug. Even if I change the mapping to *.abc there should not be a problem.

Related

FilterServletResponseWrapper replacement when migrating Richfaces to Primefaces. For file download

I am migrating a project from Richfaces to Primefaces and I am having problems getting file download to work again. The original uses a standard h:commandLink which tells the webflow to start the download by calling a function on the controller. The actual downloading is written to the output stream instead of being returned as a file.
Now my problem is the previous code sends a FilterServletResponseWrapper, but after changing the rich tags to prime, it now returns HttpSessionSecurityContextRepository$SaveToSessionResponseWrapper. These wrappers are not specified anywhere and I suspect rich sends such a type internally. So if I want to specify my own wrapper to send, how could I possibly go about that? In particular I want to use Spring's ContentCachingResponseWrapper since I need to use it's .getContentInputStream() method.
P.S. I have intentionally omitted the code, because of NDA, I am hoping this is enough information to represent the problem sufficiently. If not I will be glad to clear out any questions.
Thanks

OptaPlanner HardMediumSoftBigDecimalScore isn´t recognized like score type

I´m using OptaPlanner to solve optimization problems, I´m working with HardMediumSoftBigDecimalScore and OptaPlanner said me:
field private org.optaplanner.core.api.score.buid
in.hardmediumsoftbigdecimal.HardMediumSoftBigDecimalScore asota.lubricantselection.lsopt.domain.bearinglubricantsolution.BearingLubricantSolution.score) that returns a scoreType (class org.optaplanner.core.api.score.buildin.hardmediumsoftbigdecimal.HardMediumSoftBigDecimalScore) that is not recognized
as a default Score implementation.
If you intend to use a custom implementation, maybe set a scoreDefinition in the PlanningScore annotation.
I tried with 7.43.1 version and 7.40.0 version the same error persist.
Thank you in advance, I look forward to your comments.
I remember fixing this bug for master the other day. It was simply not hooked in.
The fix will be part of the 8.0.0.Beta1 release. The fix is not backported to 7.x at this point (if a customer submits a support ticket, we will prioritize the backport).
Workaround wise, there's nothing I can immediately think about... sorry.

Angular2 i18n at this point?

We decided to give it a spin and we started fresh project using Angular2. So far so good, but at this point we're facing an issue. At this point, what is the proper approach to i18n for Angular2? We've researched a little and found this:
https://github.com/angular/i18n
However last commit is more than 5 months old... Doesn't look like active development.
Anyone tried using angular-translate or angular-gettext? Or maybe with Angular2 it's better to wrap something JS like i18next? Anyone could share their thoughts? Maybe you faced the same problem?
Plunk was updated to Angular 2 Final: https://plnkr.co/edit/4euRQQ. Things seem to work the same as in RC7.
New i18n section has been added to Angular 2 official docs. Basically, it explains in details what happens in the plunkr above.
XLIFF is the only format for translations, no json support.
A translation source file (xliff, xlf) should be created using ng-xi18n tool:
package.json:
"scripts": {
"i18n": "ng-xi18n",
...
}
and
npm run i18n
See the Merge translation section for details about merging a translation into a component template. It's done using SystemJS Text plug-in.
Another example using Gulp http://www.savethecode.com/angular2-i18n-native-support/
Older staff:
Update based on RC7 and links provided by Herman Fransen:
I've made a minimal Plunkr example: https://plnkr.co/edit/4W3LqZYAJWdHjb4Q5EbM
Comments to plunkr:
bootstrap should provide TRANSLATIONS, TRANSLATIONS_FORMAT, LOCALE_ID with values -> setup translations
translatable items in html-templates should use directive i18n
translations are stored in .xlf file. Ties between languages is done through Id, ties with html by a value of <source> tag in xlf
currently xlf files are not used directly; a .ts file is manually created to wrap the content of xlf in an exportable variable. I guess, this should be working automagically in final release (maybe even now).
This is the first officially documented approach I found.
However, it's still barely usable. I see the following issues in the current implementation:
Language is set at bootstrap, unable to change it in run-time. This should be changed in Final.
Id of a translatable item in xlf is generated SHA. Current way to get this id is a bit messy: you create a new translatable item, use it, copy SHA id from error and paste into your i18n.lang.xlf file.
There is a big documentation pull request concerning i18n
Older staff:
Release notes https://github.com/angular/angular/blob/master/CHANGELOG.md have a record
i18n: merge translations 7a8ef1e
A big chunk of i18n was introduced in Angular 2 RC5
Unfortunately, still no documentation available.
Everyone's eager for the official implementation, but this one worked for my use case:
https://github.com/ocombe/ng2-translate
README is fairly thorough, and if you need something real particular (for me it was code-splitting) the code itself isn't too long or hard to read.
Support for i18n is now official in Angular 2 RC6
Official release blog:
https://angularjs.blogspot.nl/2016/09/angular-2-rc6_1.html
A sample of internationalization with Angular 2 RC6
https://github.com/StephenFluin/i18n-sample
More info how the new concept of i18n works in angular2:
https://lingohub.com/blog/2015/03/angular-2-i18n-update-ng-conf-2015
I found another way to implement this using pipe and service
HTML
<!-- should display 'hola mundo' when translate to Spanish -->
<p>{{ 'hello world' | translate }}</p>
TYPESCRIPT
...
// "this.translate" is our translate service
this.translate.use('es'); // use spanish
...
// should display 'hola mundo' when translated to Spanish
this.translatedText = this.translate.instant('hello world');
...
https://scotch.io/tutorials/simple-language-translation-in-angular-2-part-1
https://scotch.io/tutorials/simple-language-translation-in-angular-2-part-2
There is an official support for i18n in Angular.io here:
https://angular.io/docs/ts/latest/cookbook/i18n.html
But! As mentioned in docs:
You need to build and deploy a separate version of the application for
each supported language!
That makes this feature useless in most cases ...
Unless you will use it without CLI as described here:
https://devblog.dymel.pl/2016/11/03/angular2-and-i18n-translate-your-app/
I am putting together a POC and the official documentation is cumbersome to say the least, so I tried ngx-translate http://www.ngx-translate.com/ and I literally had the hello world working in a few minutes, there are few caveats:
I've read of people complaining about performance, because of the pipes, but reading the github issues, it seems that it is getting resolved
It is only for i18n or Translations it does not deal with i10n or Localization
There are few warning errors with Angular4 but it works anyways
long story short I liked ngx-translate if you have a small app and only need translation
I personally wanted Localization, so I am looking at
https://github.com/robisim74/angular-l10n
. It looks pretty good, but I haven't tested, so I'll let you know later, or you guys can go and we all try

zend framework 2 some validators stays in the Zend\I18n\Validator package

I have observed that some validators (Alnum, Alpha, Float, Int and PostCode) are localized into "Zend\I18n\Validator" package instead of "Zend\Validator" how the zend documentation explains.
Somebody knows because it's so.
Can I use these validators without problems?
Yes you can use them without problems. You may have to change your "use" statement or you can refer to them using their full namespace. In my current project I'm using the AnnotationBuilder to validate forms that contain floats using the #Annotation\Validator() syntax. It works quite well.
The only issue I came across was I needed to install/enable the php-intl extension on my server.

Cakephp Revision behavior hurdles validation error?

I have a CakePHP ticketing app where I am using Revision Behavior to keep revision history of each tickets. The problem I have using this behavior is, it does not display validation error messages. Here is the line I have added in the model.
public $actsAs = array('Revision' => array('limit'=>10));
When I comment this line, it displays error messages and otherwise it does not. Also, when I debug it using x-debug, I see validationErrors variable is set and has all error message values set properly.
Please shed some light here.
Edit: I am using Cake 2.1
First, be sure to get the last version of this behavior : http://alkemann.googlecode.com/svn/trunk/models/behaviors/revision.php
for integration in CAKE 2.X, the problem comes from line 980 in the createShadowModel() function:
$Model->ShadowModel->alias = $Model->alias;
The behavior gives the same alias to the base model and its shadowmodel it will save in the _revs table and that seems to mess up the validation messages.
The problem is that this behavior is loaded automatically when you access your model, and the createShadowModel() function is called even if your input doesn't validate.
One of the solution would be to comment out this line from createShadowModel() and then to add it only to every function in the behavior that will make an operation in the DB . There is surely a better way than that, like detecting in the setup() if there is need to go further to initialization, but couldn't find how to do it. So that's my first step towards at least allowing to use this behavior in Cake 2.X.
There are a few things that could be happening here. Too much for one to simply tell you what is happening since we don't have any of your code. However, I am pretty certain that this behavior, being that it was written in 2008, will have issues with CakePHP version 2.1, which just released its first alpha. There have been a lot of changes to the infrastructure of Cake that could cause this not to work. I'd say this would probably work with version 1.3 and definitely with 1.2, but getting support for 2.1 probably won't happen without updates.
That said, this is a behavior, which should only alter model code. So, there should be not impact (theoretically) on your view. Are you sure you are using the proper conventions in your code to display errors (even though commenting it out changes displayed messages).
I'd look for a 2.0+ compatible version of the behavior. Or, you could throw the code on Github and start to port it yourself. You may get some help from some Cake people.

Resources