Eclipse luna jee does not recognise view Param in jsf navigation rules - eclipse

I have to write a JSF application using navigation rules.
I have a few ManagedBeans that are mostly requestScoped. When a user clicks on a commandLink or commandButton, I want to pass a Parameter (for example the id of the current Bean) so the Bean can fill its modell with the data using this passed id to find the data in the used database.
For this reason, I used following sollution:
...
<navigation-rule>
<display-name>mainpage.xhtml</display-name>
<from-view-id>/mainpage.xhtml</from-view-id>
<navigation-case>
<from-action>#{postBean.findById(post.id)}</from-action>
<from-outcome>single</from-outcome>
<to-view-id>/postpage.xhtml</to-view-id>
<redirect include-view-params="true">
<view-param>
<name>id</name>
<value>#{postBean.post.id}</value>
</view-param>
</redirect>
</navigation-case>
</navigation-rule>
...
This works and the view-param is seen in the URL but Eclipse always shows the error:
cvc-complex-type.2.4.a: Invalid Content was found starting with element 'view-param'. One of '{"http://xmlns.jcp.org/xml/ns/javaee":redirect-param}' is expected.
Do I have to use something else, does eclipse luna jee not recognize the view-param tag, how can I remove this error?
(The faces config is version 2.2, I do not use a framework like primefaces or richfaces)

It is a known issue "redirect-param are ignored #3403" with Mojarra implementation 2.2. You have to use view-param instead of redirect-param to get it work. It is fixed in 2.3.

Related

How to accomplish drop-down lists in KIE workbench?

I'm new to JBPM and am trying to wrap my head around a new project, and recently noticed that while trying to define some user task forms I couldn't find a form option for a drop-down list
At this point my knowledge of the technology is pretty small, and this seems like a strange limitation at first glance, which should have an easy work-around, but I'm having difficulty finding a quick and dirty solution.
Is this something I'd have to code in Eclipse, or something else?
The answer that #cego provides is correct for "hard-coded" values, if you want to load dynamic values (from a database for example) you can use the Select Box field type and configure it to use a SelectValuesProvider that calculates the combo values.
To create a SelectValuesProvider you should create a java project with a mvn dependency to:
<dependency>
<groupId>org.jbpm</groupId>
<artifactId>jbpm-form-modeler-api</artifactId>
</dependency>
Once you did that you can create your class that implements org.jbpm.formModeler.core.config.SelectValuesProvider. This interface provides two methods:
String getIdentifier(): should return a unique String that identifies this provider. This String will be shown on the Select Box configuration popup.
Map getSelectOptions(Field field, String value, FormRenderContext renderContext, Locale locale): This method have to return a Map containting the key, text that are going to be load on the Select box. The received parameters are:
Field field: the configuration of the field that is going to be evaluated.
String Value: the current value of the field
FormRenderContext renderContext: a class that contains all the information about the form that is rendered at that moment.
Locale locale: the locale in which is being rendered the form.
Once you've created this provider, you must compile your project and put the jar on the server classpath and restart it. After doing that you'll be able to create a form (or edit an existing one), add a Select Box field and choose your provider on the "Data provider" combo box.
Hope it helps, if you have any doubt please ask and I'll try to create an example.
Regards,
Pere
Ok, for old versions you can do it turning a textbox to a combobox using a RangeProvider. This is a very similar solution to the previous one.
First you should create java project with a mvn dependency to:
<dependency>
<groupId>org.jbpm</groupId>
<artifactId>jbpm-form-modeler-api</artifactId>
</dependency>
After that you have to create your RangeProvider class that implements org.jbpm.formModeler.api.model.RangeProvider and implement it's methods. As the SelectValuesProvider on the previous example this interface provides two methods:
- String getType(): A unique String to identify the provider
- Map getRangesMap(String namespace): This method have to return a Map containting the key, text that are going to be load on the combo box. It only receives a String parameter, it is an identifier that allows you to get all the information about the form that is being rendered.
Also you have to create a META-INF/beans.xml file to allow to lookup your provider via CDI (I missed this step on the previous example, sorry).
As the previous example, once you've created the provider you must compile your project and put the jar on the server classpath and restart it.
When the server is started you have to create a new form (or open an existing one), add a TextBox field, edit it's properties and write the string returned by your RangeProvider's getType method on the "Range value" property.
Save the field properties and if everything is fine the field would be rendered as a combobox showing the values returned by your provider.
To create a select element(drop-down list) look for "Setting a Range Formula" in this part of the documentation: http://docs.jboss.org/jbpm/v6.1/userguide/chap-formmodeler.html#sect-formmodeler-FormulasExpression

EE 1x plugin wont parse nested plugin tags

I wrote a simple and short expressionengine 1x plugin which works well for what I needed.
It is working fine with the following code:
{exp:iv_simple_rss_parser feed="http://imccomunicacion.tumblr.com/rss" strip_tags="yes"}
Title {title}
{exp:word_limit total="20"}{description}{/exp:word_limit}
{link}
{/exp:iv_simple_rss_parser}
I needed to limit the {description} var so I wanted to use the word_limit plugin, like you can see. The fact is that all works ok but the description tag is no limited by word_limit.
It seems that EE is not parsing that nested plugin, it just ignores it, like it was not there.
How can I make EE to parse the word_limit plugin when it is inside of my plugin??
Thanks!
This is because the inner-most plugin tag parses first, and at that point, {description} doesn't exist yet. You can reverse the parse order by adding parse="inward" to your outer plugin tag:
{exp:iv_simple_rss_parser feed="http://imccomunicacion.tumblr.com/rss" strip_tags="yes" parse="inward"}
Title {title}
{exp:word_limit total="20"}{description}{/exp:word_limit}
{link}
{/exp:iv_simple_rss_parser}

Adding <h:form> causes java.lang.IllegalStateException: Cannot create a session after the response has been committed

I'm facing the following exception in a very simple JSF 2 page after adding <h:form>:
java.lang.IllegalStateException: Cannot create a session after the response has been committed
at org.apache.catalina.connector.Request.doGetSession(Request.java:2758)
at org.apache.catalina.connector.Request.getSession(Request.java:2268)
I'm using Mojarra 2.1.3 and PrimeFaces3.0M4, on Tomcat 7.0.22 and JDK 7.
The page is a very basic data table:
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:p="http://primefaces.org/ui">
<h:head>
</h:head>
<h:body>
<h:form>
<p:dataTable var="car" value="#{tableBean.cars}">
......
</p:dataTable>
</h:form>
</h:body>
</html>
The page shows correctly on the browser, but on the console I see the exception. The Exception does disappear if I remove the <h:form>.
How is this caused and how can I solve it?
This is a known problem and has been reported by yours truly as issue 2215. This will occur when the response buffer has overflowed (due to large content) and the response is been committed before the session is been created. This is result of bit overzealous attempts of Mojarra to postpone "unnecessary" session creation as much as possible (which is at its own a Good Thing though).
Until they get it fixed, there are several workarounds:
Create a Filter which does HttpServletRequest#getSession() before FilterChain#doFilter(). Advantage: no need to change JSF configuration/code. Disadvantage: when you want to avoid unnecessary session creation yourself as well.
Call ExternalContext#getSession() with true in bean's (post)constructor or preRenderView listener. Advantage: actually, nothing. Disadvantage: too hacky.
Add a context parameter with name of com.sun.faces.writeStateAtFormEnd and value of false to web.xml. Advantage: unnecessary session creation will be really avoided as opposed to #1 and #2. Disadvantage: response will now be fully buffered in memory until </h:form> is reached. If your forms are not extremely large, the impact should however be minimal. It would however still fail if your <h:form> starts relatively late in the view. This may be combined with #4.
Add a context parameter with name of javax.faces.FACELETS_BUFFER_SIZE and a value of the Facelets response buffer size in bytes (e.g. 65535 for 64KB) so that the entire HTML output or at least the <h:form> (see #3) fits in the response buffer. Advantage/disadvantage, see #3.
Add a context parameter with name of javax.faces.STATE_SAVING_METHOD and value of client to web.xml. Advantage: session will not be created at all unless you have session scoped beans. It also immediately solves potential ViewExpiredException cases. Disadvantage: increased network bandwidth usage. If you're using partial state saving, then the impact should however be minimal.
As to why the problem disappears when you remove <h:form>, this is because no session needs to be created in order to store the view state.
Update: this has as per the duplicate issue 2277 been fixed since Mojarra 2.1.8. So, you can also just upgrade to at least that version.
With the new version 2.1.21 released yesterday of javax.faces this problem seems to have disappeared.
Declare the new version:
<dependency>
<groupId>org.glassfish</groupId>
<artifactId>javax.faces</artifactId>
<version>2.1.21</version>
</dependency>
and replace the javax.faces.jar in the glassfish modules folder replacing the javax.faces.jar for the new version 2.1.21.
In my case (myfaces-2.2.8 & Tomcat 8.0.23) the Problem was a typo in the welcome-file of web.xml.
While debugging i saw, that Tomcat created as expected a 404, but somehow myfaces tried to access afterwards the Session, which caused then a java.lang.IllegalStateException: Cannot create a session after the response has been committed.
Using a valid page in welcome-file of web.xml fixed the Problem for me.
You may need to add an <f:view> and </f:view> before and after h:form elements, plus add the link to you html tag for jsf tags
<html xmlns:f="http://java.sun.com/jsf/core">
for this to work.
If you are using Spring MVC and call is made by Spring Forms then we should use GET method instead of POST(to fetch data) and there should be no input field we can use intead.

Richfaces drag and drop object not defined?

Mozilla is spitting out
DnD is not defined
errors on all of my rich:dragSupport and rich:dropSupport tags. When I check out the generated javascript the DnD object is where it should be and things look ok. Any ideas on why my DnD object is not defined? Has anyone come accross gotchas with using richfaces dnd?
We are using Richfaces 3.2.1 (drag and drop started in 3.0.0 acording to docs)
An example of how we are using this:
<a4j:outputPanel><rich:panel>
<rich:dropSupport dropListener="#{myBean.dropAction}>
<a4j:actionParam value="#{someData}" name="paramData" />
</rich:dropSupport>
<a4j:repeat value="#{myBean.list}" var="item">
<a4j:outputPanel>
<rich:panel>
<rich:dragSupport dragValue="#{someOtherData}">
<a4j:actionparam value="#{someOtherOtherData}" name="secondParam" />
<h:outputText value="#{item.name}"></h:outputText>
</rich:dragSupport>
</rich:panel>
</a4j:outputPanel>
</a4j:repeat>
</rich:panel></a4j:outputPanel>
My Problem: typo in naming of JBoss portlet deployment xml files
Other things to check (from week of research):
Are you deploying the necessary richfaces jar files?
Do you have other js scripts that are causing namespace issues like jQuery or prototype?
It's an old thread, but my answer is: Inside tag < rich:dragSupport/>, must be included < rich:dndParam>.
See http://livedemo.exadel.com/richfaces-demo/richfaces/dragSupport.jsf?tab=usage&cid=289435 for more information.
PD: Sorry for my rustic English, I'm from Argentina...

Intermitent problem with Struts 1.2.8 HTML taglib and JBoss

I have a legacy Struts 1.2.8 application that I'm maintaining and porting from Oracle Application Server (OAS) 10g to JBoss 4.2.3. I have a JSP that uses the Struts HTML tag library. The JSP page is backed by EJBs. The user enters an item number and the page displays the details of the item (e.g. item from a product catalog).
On the first 3 times I use this page, the item details are returned correctly. But for some reason, on the fourth submission of the page and on subsequent submissions, some of the item information is missing. I'm using
<html:hidden property="itemNumber"/>
<html:text property="itemNumber"/>
tags. The bizarre part of this problem is that I can't recreate the problem in OAS. In addition, if I replace the above html:text tag with
<input type="text" value="<%=itemForm.getItemNumber() %>" >
The code works correctly. My guess is that this is a session/request/scope problem. But I haven't found the correct configuration.
Is there special configuration required for Struts in JBoss?
Check the scope being used for the action in the struts-config.xml file. Most likely you probably want the scope to be request.
The problem was caching in the Jasper JSP engine. The default configuration is
enablePooling - Determines whether tag handler pooling is enabled. true or false,
default true.
I was able to set enablePooling to false and my problem was resolved. I assume this is a bug in Jasper. This bug appeared when a JSP custom tag (e.g. html:hidden) is followed by a jsp:attribute where the name is "value". See below.
<html:hidden property="itemNumber"/>
.
.
<html:text property="regularPrice" maxlength="9" readonly="<%=disabled%>"
tabindex="9" onkeyup="onRegularPriceChanged(this)">
<jsp:attribute name="value">
<webmodules:currency onlyDisplayValue="false">
<jsp:attribute name="currencyValue">
<bean:write name="updateItemForm" property="regularPrice"/>
</jsp:attribute>
</webmodules:currency>
</jsp:attribute>
</html:text>
There seems to be a namespace and caching conflict between the "value" that is set by the html:hidden and the "value" that is set by the jsp:attribute. After the JSP page was used twice the cached value set by the jsp:attribute was being used as the value for html:hidden.