Why is "cc" null inside a commandButton's action in my Facelets composite component? - facelets

I have a Facelets Composite component that includes, among other things, a commandButton:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html>
<ui:component xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:cc="http://java.sun.com/jsf/composite"
xmlns:ice="http://www.icesoft.com/icefaces/component"
xmlns:nc="http://compositecomps.sss.evla.nrao.edu/jsf"
xmlns:opt="http://java.sun.com/jsf/composite/components/opt"
xmlns:undo="http://undo.sss.evla.nrao.edu/jsf"
xmlns:n="http://sss.evla.nrao.edu/jsf"
xmlns:f="http://java.sun.com/jsf/core">
<cc:interface>
<cc:attribute name="value" type="edu.nrao.sss.tools.obsprep.bulkedit.BulkEditor" required="true"/>
<cc:attribute name="loop" type="edu.nrao.sss.tools.obsprep.uiactions.project.scan.ScanLoopUIActions" required="true"/>
</cc:interface>
<cc:implementation>
<ui:param name="loop" value="#{cc.attrs.loop}"/>
<ui:param name="val" value="#{cc.attrs.value}"/>
<ice:panelGroup id="wizStep1"
rendered="#{val.readyToSelect}">
<nc:header value="select fields to filter on"/>
<ice:commandButton value="#{val.nameField.value}" action="#{val.select}"/>
<table cellpadding="5">
<thead>
<tr>
<th></th><th>Field</th><th>Search For</th><th></th>
</tr>
</thead>
<tbody>
<opt:bulkEditField value="#{val.nameField}">
<f:facet name="summary">
<ice:inputText value="#{val.nameField.value}"/>
</f:facet>
</opt:bulkEditField>
</tbody>
</table>
<ice:commandButton value="Select" action="#{val.select}"/>
</ice:panelGroup>
</cc:implementation>
</ui:component>
I've changed the code to use val.nameField.value as the label for the first command button to demonstrate the problem.
When I use this component in a page, it renders the button and a list of searchable fields below it. If I change the value of the name field, the button label changes.
However, if I click the button, I get a target unreachable exception:
Caused by: javax.el.PropertyNotFoundException: /resources/components /opt/bulkEdit.xhtml #25,79 action="#{val.select}": Target Unreachable, identifier 'val' resolved to null
I feel like I must be missing something fundamental to how these composite components work. This worked fine as a tag file under facelets/JSF 1.2. In the process of upgrading to JSF 2.0, I wanted to move on to using composite components so I can have a defined interface.
If I stop using <ui:param/> and put cc.attrs.value in directly, it tells me that cc is null.
I thought this could be a bug in icefaces, but switching to plain <h:commandButton/> does the same thing.
Thanks for any advice you may have.

This is a bug in ICEfaces 2.0. You have a UISeries (panelTabSet or dataTable) that contains the composite component. See http://jira.icesoft.org/browse/ICE-7142. It's fixed in 3.0.

Related

<h:commandLink> action not invoke if include with <ui:include>

If I place inside an include file, the action will not call back bean.
Main File:
<h:form id="ifLogin">
<h:panelGrid
rendered="#{userSession.isLogin}"
columns="2" columnClasses="columnAlignLeft, columnAlignRight"
border="0" cellpadding="0">
<ui:include src="\test.xhtml" />
...
</h:panelGrid>
</h:form>
Include file (test.xhtml)
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:a4j="http://richfaces.org/a4j"
xmlns:rich="http://richfaces.org/rich">
<h:panelGrid border="0" columns="4">
<h:graphicImage value="#{msg.urlImageHome}"
style="height:26px;width:26px;" />
<f:subview>
<h:commandLink value="#{msg.home}" style="font-size: small;" immediate="true"
action="#{pageNavigationBean.updateCeaAppName}">
<f:param name="requestName" value="CEA_MAIN_PAGE" />
<f:param name="ceaAppName" value="" />
</h:commandLink>
</f:subview>
</h:panelGrid>
</ui:composition>
The workaround is take out include file, directly place the code to main file as below:
Main file (without using include)
<h:form id="ifLogin">
<h:panelGrid
rendered="#{userSession.isLogin}"
columns="2" columnClasses="columnAlignLeft, columnAlignRight"
border="0" cellpadding="0">
<h:panelGrid border="0" columns="4">
<h:graphicImage value="#{msg.urlImageHome}"
style="height:26px;width:26px;" />
<f:subview>
<h:commandLink value="#{msg.home}" style="font-size: small;" immediate="true"
action="#{pageNavigationBean.updateCeaAppName}">
<f:param name="requestName" value="CEA_MAIN_PAGE" />
<f:param name="ceaAppName" value="" />
</h:commandLink>
</f:subview>
</h:panelGrid>
...
</h:panelGrid>
</h:form>
I use richface 4.3.1 Odd is this problem not happen when I run from local GAE. After deploy online to GAE, problem occour (i.e if using include then action will not trigger.
Is that a bug in jsf? or richface implementation or GAE? Any help?
Problem identify
It is not cause by using <ui:include>
The problem came out when the include file is dynamic generate from back bean, for example:
<ui:include src="#{pageNavigationBean.appDropDownMenuUrl}" />
If explicit mention the url, it work, for example:
<ui:include src="\test.xhtml" />
Well, if running from my local GAE, both way are working but when deploy online, I need use explicit location instead generate from bean. May be that is due to GAE problem where state is save at Client side (javax.faces.STATE_SAVING_METHOD).
I can't reproduce the problem with exactly the same included code (test.xhtml), but here are some recommendation:
Escape '>' characters (replace >>> by >>>)
Specify id attribute for f:subview (it is required according to tld)
Change backslash ('\') to slash ('/'). So inclusion would be <ui:include src="/test.xhtml" />

Obout Suite Superform DateField issue

I am using the Obout Suite in a website.
I have a SuperForm control in which I have inserted some controls like BoundFields or DateFields.
The problem is that when I select a date at the DateField Calendar, the textbox associated doesn't refresh the value of the date.
I have something like:
<obout:SuperForm ID="SuperForm2" runat="server" AutoGenerateInsertButton ="true" AutoGenerateEditButton="false" AutoGenerateDeleteButton="false" AutoGenerateRows="false" DataKeyNames="IdDocumento" DefaultMode="Insert" Width="525" DataSourceID="SqlDataSource2">
<Fields>
<obout:BoundField DataField="DocumentType" HeaderText="Name" FieldSetID="FieldSet1" />
<obout:DateField DataField="OrderDate" HeaderText="Order Date" FieldSetID="FieldSet2" DataFormatString="{0:MM/dd/yyyy}" ApplyFormatInEditMode="true" />
<obout:DateField DataField="RequiredDate" HeaderText="Required Date" FieldSetID="FieldSet2" DataFormatString="{0:MM/dd/yyyy}" ApplyFormatInEditMode="true" />
</Fields>
<FieldSets>
<obout:FieldSetRow>
<obout:FieldSet ID="FieldSet1" />
</obout:FieldSetRow>
<obout:FieldSetRow>
<obout:FieldSet ID="FieldSet2" />
</obout:FieldSetRow>
</FieldSets>
</obout:SuperForm>
The tag prefix is:
<%# Register TagPrefix="obout" Namespace="Obout.SuperForm" Assembly="obout_SuperForm" %>
The "obout_Calendar2_Net.dll" is referenced by the solution.
Am I forgotting something?
Thanks in advance.
Cartojal
Well, finally I found the solution. If you are using .net 4.0, like me.... you must to add the attribute clientIDMode="AutoID" to the section "pages" at the web.config file:
<pages clientIDMode="AutoID">
....
</pages>
This generate the asp.net controls ids like past versions of .net

iBatis - Why is sqlMapConfig.xml unable to find the sql maps defined in it?

I have a sqlMapConfig.xml that has three SQLMaps defined in it.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE sqlMapConfig
PUBLIC "-//ibatis.apache.org//DTD SQL Map Config 2.0//EN"
"http://ibatis.apache.org/dtd/sql-map-config-2.dtd">
<sqlMapConfig>
<!-- Statement namespaces are required for Ibator -->
<settings enhancementEnabled="true" useStatementNamespaces="true"/>
<!-- Setup the transaction manager and data source that are
appropriate for your environment
-->
<transactionManager type="JDBC">
<dataSource type="SIMPLE" >
<property name="JDBC.Driver"
value="com.mysql.jdbc.Driver"/>
<property name="JDBC.ConnectionURL"
value="jdbc:mysql://localhost:3306/sug"/>
<property name="JDBC.Username"
value="root"/>
<property name="JDBC.Password"
value="admin"/>
</dataSource>
</transactionManager>
<!-- SQL Map XML files should be listed here -->
<sqlMap resource="com/tatakelabs/dbmaps/categories_SqlMap.xml" />
<sqlMap resource="com/tatakelabs/dbmaps/pro_SqlMap.xml" />
<sqlMap resource="com/tatakelabs/dbmaps/pro_category_SqlMap.xml" />
</sqlMapConfig>
I get a runtime error - Cause: java.io.IOException: Could not find resource com/tatakelabs/dbmaps/categories_SqlMap.xml
categories_SqlMap.xml is present in that location. I tried changing the location of the map xml, but that did not help. sqlMapConfig.xml validates against the DTD. categories_SqlMap.xml also validates against the right DTD. I am at my wits end trying to figure out why it can't find the resource. The sqlMap files are generated by iBator.
This was happening because the sqlmap file location was not getting copied to target. Added a copy goal and that fixed it.
I had the same problem. It appears the problem lies with the location of the config file. Thus, its in relation of the project resource structure.
I moved the config file in the same package as the mapper classes and it worked. In this case try moving all the resources to this package and update the resource attributes to:
<sqlMap resource="categories_SqlMap.xml" />
<sqlMap resource="pro_SqlMap.xml" />
<sqlMap resource="pro_category_SqlMap.xml" />
Solved it.
I moved the xml file to where the Pojo was located and provided the path as follows:
<sqlMap resource="com/heena/ibatis/model/jsr/jsr.xml" />
And it worked.
place it ...src\java\abc.xml under the Source Packages directory.
If you are using Spring, you can use a SqlMapClientFactoryBean specifying property "mappingLocations". In this property you can specify a generic path, such as "com/tatakelabs/dbmaps/*_SqlMap.xml" or with a variable such as ${mapfiles}, that will be resolved by Spring as an array of file names. This lets you omit sqlMap element in sqlMapConfig. This technique will run with iBatis 2.3.4 on. However sql-map-config-2.dtd is also contained inside iBatis.jar, so you can experience some parsing errors, as /com/ibatis/sqlmap/engine/builder/xml/sql-map-config-2.dtd may have a bug. In this case you may want to replace it inside the jar with the one from the URL:
http://ibatis.apache.org/dtd/sql-map-config-2.dtd.

JSF 1.2 JSP 2.0 Simple Custom Tag File with Attributes

So I'm trying to do a custom tag in a JSF 1.2 environment with JSP 2.0. I'm ultimately trying to pass a java Object as an attribute with EL, but I was getting a "org.apache.jasper.JasperException: jsp.error.beans.property.conversion" exception. So I took a step back and tried to just get a simple custom tag to work. I was successful in printing hello world. I then tried to pass it a simple String attribute and just print that. This was not working. The attribute would not print to the screen. The static "hello world" text does just not the attribute.
WEB-INF/tags/helloworld.tag:
<?xml version="1.0" encoding="UTF-8"?>
<jsp:root version="2.0" xmlns:jsp="http://java.sun.com/JSP/Page" xmlns:ui="http://www.sun.com/web/ui" xmlns:c="http://java.sun.com/jsp/jstl/core" xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html">
<jsp:directive.attribute name="message" required="true"/>
<ui:staticText id="asdf" text="hello world: #{message}"/>
</jsp:root>
MyBean.jsp then defines the tag namespace: xmlns:tags="urn:jsptagdir:/WEB-INF/tags" and then calls the tag like so:
<tags:helloworld message="Test message"/>
I am using jboss 4.0.4 to deploy the war file.
Try to set rtexprvalue="true" in "message" attribute ie:
<jsp:directive.attribute name="message" required="true" rtexprvalue="true"/>

CakePHP: How do I reference a flash asset in my plugin's webroot?

I'm using CakePHP to build a plugin and am trying to add a flash asset to my view.
The tag looks like this:
<object type="application/x-shockwave-flash" data="unknown_url" id="VideoPlayback">
<param name="movie" value="unknown_url" />
<other params....>
</object>
Unfortunately I don't know what url to point to!
Given that my plugin is using standard structure (for CakePHP 1.3x) i would like to access my flash file which is stored here:
app/plugins/my_plugin/webroot/flash/my_flash_file.swf
I know that in the php side /my_plugin/flash/my_flash_file.swf gets rewritten to route correctly (this works just fine when I try something like $this->Html->img('URL') ), but I don't know of any Html Helper function to create object tags.
Any help would be appreciated!
You can use $this->Html->url() to create correct URLs.
<object type="application/x-shockwave-flash" data="<?php echo $this->Html->url( ' /my_plugin/flash/my_flash_file.swf' ); ?>" id="VideoPlayback">
<param name="movie" value="<?php echo $this->Html->url( ' /my_plugin/flash/my_flash_file.swf' ); ?>" />
<other params....>
</object>
<?php echo $html->url('/webroot/uploadify/uploadify.swf');?>
it will give you link like /your_app_name/webroot/uploadify/uploadify.swf

Resources