JSF own component
Hi.
I am developing own JSF component, something like Switch compoennt which have oracle - ADF Faces Components.
On JSF page will be this tag:
<s:switch value="facet2">
<facet name "facet1">..... </facet>
<facet name "facet2">.....</facet>
</s:switch>
But I don't know how can I render only one facet, for example facet with name facet2.
I don't know if I must develop own renderer, or in which phase encoding I could specify which facet, can be render.
Does anybody know where can I find more informations about it, or some good example?
Thank yopu very much for your answer.
1) return true to getRendersChildren()
2) in your own renderer you fetch the "choosen facet" ... guess you already know how...
3) fetch the facets only child
4) facet.kid.encodeBegin();
if (!facet.kid.getRendersChildren()) {facet.kid.encodeChildren()};
facet.kid.encodeEnd();disclaimer: answer given from memory -> might be unsharp on actual method-names, but when you look at the javadoc you should figure it out
hth
Alexander
Similar Messages
-
I was looking for a quick solution for a JSF iterator, because i dont want to use the h:dataTable i have to write my own component, and here is what i came up with.
public class JSFUIDataIterator extends UIData{
public void encodeChildren(FacesContext oContext) throws IOException {
if (oContext == null){
throw new NullPointerException();
int iProcessed = 0;
int iRowIndex = getFirst() - 1;
int iRows = getRows();
Iterator oKids = getChildren(this);
do{
if(iRows > 0 && ++iProcessed > iRows)
break;
setRowIndex(++iRowIndex);
if (!isRowAvailable())
break;
for(; oKids.hasNext();){
UIComponent oKid = (UIComponent)oKids.next();
encodeRecursive(oContext,oKid);
} while(true);
protected Iterator getChildren(UIComponent oComponent){
List oResults = new ArrayList();
for(Iterator oKids = oComponent.getChildren().iterator(); oKids.hasNext();){
UIComponent oKid = (UIComponent)oKids.next();
if(oKid.isRendered())
oResults.add(oKid);
return oResults.iterator();
private void encodeRecursive(FacesContext oContext,UIComponent oComponent) throws IOException{
if (!oComponent.isRendered()){
return;
oComponent.encodeBegin(oContext);
if (oComponent.getRendersChildren()){
oComponent.encodeChildren(oContext);
else{
Iterator oChildren = getChildren(oComponent);
for(;oChildren.hasNext();){
UIComponent oChildComponent = (UIComponent)oChildren.next();
encodeRecursive(oContext,oChildComponent);
oComponent.encodeEnd(oContext);
}not want to be bothered by creating a renderer this component will render itself, but there is a problem, even though its iterating all the data elements its displaying the first data item. i missed something minor that i cant figure out. can anyone help?I haven't got a reply so i went to look at my code again, and i managed to identify the problem.
I hope this code will help all those who want to use the iterator tag in JSF.
this simple custom component will give you more control over your data elements
here is the code for the custom component.
public class DataIterator extends UIData{
public void encodeChildren(FacesContext oContext) throws IOException {
if (oContext == null){
throw new NullPointerException();
int iProcessed = 0;
int iRowIndex = getFirst() - 1;
int iRows = getRows();
do{
if(iRows > 0 && ++iProcessed > iRows)
break;
setRowIndex(++iRowIndex);
if (!isRowAvailable())
break;
Iterator oKids = getChildren(this);
for(; oKids.hasNext();){
UIComponent oKid = (UIComponent)oKids.next();
encodeRecursive(oContext,oKid);
} while(true);
protected Iterator getChildren(UIComponent oComponent){
List oResults = new ArrayList();
for(Iterator oKids = oComponent.getChildren().iterator(); oKids.hasNext();){
UIComponent oKid = (UIComponent)oKids.next();
if(oKid.isRendered())
oResults.add(oKid);
return oResults.iterator();
private void encodeRecursive(FacesContext oContext,UIComponent oComponent) throws IOException{
if (!oComponent.isRendered()){
return;
oComponent.encodeBegin(oContext);
if (oComponent.getRendersChildren()){
oComponent.encodeChildren(oContext);
else{
Iterator oChildren = getChildren(oComponent);
for(;oChildren.hasNext();){
UIComponent oChildComponent = (UIComponent)oChildren.next();
encodeRecursive(oContext,oChildComponent);
oComponent.encodeEnd(oContext);
}you only need these three methods in your component, i have stripped out logging and comments to keep the size of this post smaller, the rest is pretty straight forward.
you need a CustomTag class for the component and it should at least take two attributes : items and var.
your tag library should look something like this:
<name>forEach</name>
<tag-class>myjsf.DataIteratorTag</tag-class>
<body-content>JSP</body-content>
<attribute>
<name>items</name>
<required>true</required>
<rtexprvalue>true</rtexprvalue>
<type>java.lang.String</type>
</attribute>
<attribute>
<name>var</name>
<required>true</required>
<rtexprvalue>false</rtexprvalue>
<type>java.lang.String</type>
</attribute>in the jsp page here is my sample file:
<%@taglib uri="/WEB-INF/data-iterator.tld" prefix="tbc" %>
<faces:view>
<faces:verbatim>
<table>
</faces:verbatim>
<tbc:forEach items="#{myCollection.musicTitles}" var="oRow">
<faces:verbatim>
<tr style="background-color:#EEEEEE;">
<td>
</faces:verbatim>
<html:outputText value="#{oRow}"/>
<faces:verbatim>
</td>
</tr>
</faces:verbatim>
</tbc:forEach>
<faces:verbatim>
</table>
</faces:verbatim> -
JSF-Custom Component with EventHandling
Dear All,
I wanted to write my own component with event handling.
This is my requirement:
In my JSP, I'll put my cusom component tag for displaying 10 records and with prev and next buttons. after clicking prev button, i should get previouse 10 records and if i click next button, i should get next 10 records.
so, my component should render
1. 10 records
2. Prev button
3. Next button.
After clicking prev button it should render previouse 10 records and also prev and next button.
I do not know whether it is possible with JSF or not and also i'm not finding any example which explaining above situation.
My jsp should contain only my custom tag like
<mine:listRecords/>
Tag Handler of listRecords tag should render 10 records and prev and also next button. After clicking prev, i should get 10 previouse records and and both the buttons and so on.
advanced thanks,
ramIt is certainly possible to write a component that embeds its own navigation and paging as you describe. On the other hand, you can also assemble this kind of functionality out of a combination of the existing simple components. The "repeater" example illustrates exactly the kind of application you are talking about (and the same techniques will work fine with the standard <h:dataTable> component as well).
Craig -
Hi
I have created a JSF cutom component , which has some javascript files. If i use the component within the same project my path for accessing the JS files is :- js/task.js (Its in public/html folder) .
My problem is that when I use this custom component in some other project i am not able to access the js file ( Js file are deployed with other source file in ADF Library Jar) . As I have to hard code the path of JS files in the render can any one please tell me what will be the path for accessing the JS files.
i heard ADFLibraryFilter is used for the purpose. Anyone please shed more light on it.Thanx Frank for your help .
I am generating html from the rendererm, in the encodeBegin method i have now written <script type="text/javascript" src="adflibResources/js/task.js"></script>
But still the script isn't loading on the page
I added the following code in web.xml but Jdeveloper (Studio Edition Version 11.1.1.1.0) is complaining that "refernce oracle.adf.library.webapp.LibraryFilter and oracle.adf.library.webapp.ResourceServlet not found. I am using Fusion Web Application (ADF) as the application template.
<filter>
<filter-name>ADFLibraryFilter</filter-name>
<filter-class>oracle.adf.library.webapp.LibraryFilter</filter-class>
<init-param>
<param-name>provider-lazy-inited</param-name>
<param-value>true</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>ADFLibraryFilter</filter-name>
<url-pattern>/*</url-pattern>
<dispatcher>FORWARD</dispatcher>
<dispatcher>REQUEST</dispatcher>
</filter-mapping>
<servlet>
<servlet-name>adflibResources</servlet-name>
<servlet-class>oracle.adf.library.webapp.ResourceServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>adflibResources</servlet-name>
<url-pattern>/adflib/*</url-pattern>
</servlet-mapping> -
hi every body
i am using Oracle Jdeveloper 11g release 2
i wanted to create a Calendar Component
for this i used JSF Declarative Component
i added a RichInputText to page and a Button for opening calendar Dialog
when for first time i open Calendar Dialog and select a day ,
value of this day return to RichInputText truly but
when i wanna to open it for second time that has an error
error is:
Error:dateValue is Read only
i have to tell you dateValue is name of Attribute on JSF Declarative Component
can anybody help me?i found a solution for this problem
thanks -
Hello Suners,
I'm developing a JEE application and using mojarra jsf implementation. I need to find a JSF Menu component that i can use in my app.
Regards,abulseed wrote:
I need to find a JSF Menu component that i can use in my app.You would be better off creating your menus using Cascading Style Sheets (CSS). JSF menuing often involves JavaScript of some sort which won't work if the user has JavaScript turned off. CSS menuing guarantees that your menu always work (even with Javascript turned off) and it's better by design, not to mention less annoying to users.
Googled for 'CSS menu' - there are heaps of examples out there that you can use.
Edited by: user2412 on Apr 5, 2011 12:30 AM -
JSF table component with paging
Are you aware of any existing JSF table component with both navigation and paging ?
I want to display the content of a database table with a large number of rows. The table component should be able to navigate through the entire table content, but building only a small ResultSet and dinamically populate it with data as we perform navigation.
Thanks,
CosminThanks for the answer.
But data scroller just takes a ResultSet and display it with navigation. It doesn't know about the total number of rows in the table. It only display the number of records in the ResultSet.
What I am looking for is a data scroller which based on some input parameters knows how to split the table in several ResultSets, dinamically change the ResultSet and display the total number of rows in the table and not in the current ResultSet. -
JSF Tab component and Dynamic Faces AjaxZone
Has anyone tried to use a JSF Tab Component in a Dynamic Faces Ajax Zone. I would like to try to have a page that has a list of the alphabet, each tab being one letter and then adding terms an definitions to each tab. Do you have any comments or suggestions regarding doing this. I am at a loss as to how to make the tab component respond when clicking on it in the ajaxZone. any help would be appreciated. thnx
The Scales and Tomahawk libraries provides a tabbed panel.
But basically tabs are nothing less or more than a bunch of block elements layered over each other with the same amount of buttons or links at the top. If a tab click doesn't require a trip to the server, then you can just load all tab blocks at once and use Javascript+DOM to switch between tab blocks, e.g. one block should be displayed using element.style.display='block' and all other blocks should be hidden using element.style.display='none'. If a tab click require a trip to the server (to preinitialize stuff or so), then you can use the 'rendered' property of the tab block element (which can be <h:panelGroup style="display:block;" rendered="#{myBean.showTab == 1}" /> or so).
For styling of the tab blocks and tab buttons/links just use CSS. -
JSF Calendar Component JS error
Hi everyone,
I have problem with JSF Calendar component. JSP version is 1.2 so we are using com.sun.rave.web.ui.component.Calendar class.
When HTML code is generated some id missing. For example:
JavaScript tries to find subForm:startCalendar:_datePicker:row5, but there is only subForm:startCalendar:_datePicker:row4.
This cause JS error at line 249 in calendar.js:
this.lastRow = document.getElementById(rowId);
this.lastRow.style.display = "none"; //error is here this.lastRow is nullAfter few reloads and manual date change calendar seem to work fine for a while, but it can stop at anytime. There are no errors in Tomcat logs (we are using Tomcat 5.5, but we have same error with Glassfish 2).
Here is JSP code:
<ui:calendar binding="#{Index.startCalendar}" dateFormatPattern="dd.MM.yyyy" id="startCalendar" style="position: absolute; left: 120px; top: 96px"/>I had observed that the code for UI:Calendar Component looks up defaulttheme.jar file which will be avaialble with Sun studio creator or with UI tag jars ...... for its JS files, Images and style sheets etc .
I tried seeing the contents in the JS files and there is a JS file specifically for Calendar Component ie calendar.js ... editing the same i came to see this
// This does not work for August (08) and September (09) but it works
// for all the other months????
function ui_Calendar_setCurrentValue() {
var curDate = this.field.value;
var matches = true;
but cant see Feb month there...
It the problem with the code in teh JS file that they are using to generate the component...
sooo the only solution would be to get the latest jars fixing that issue (defaulttheme.jar)
I tried googling out for teh latest jars for the same i coudnt find any such...
This is my investigation on this issue.Hope only code fix kills the flaw
If any one gets a solution or workaround pls post ASAP to help us.+
Edited by: Shivaji. on Feb 3, 2009 4:44 AM -
Jsf datatable component + java.sql.SQLException
I get the following error when implementing a JSF DataTable component using
JDeveloper 10.1.3.1.
javax.faces.FacesException: java.sql.SQLException: Io exception: Socket closed
I am able to follow the article in this link:
http://www.oracle.com/technology/oramag/oracle/06-jan/o16jsf.html
I can get the table generated, but it occurred to me that the example in this article does not include logic to close the statement, resultset, and connection. Sure enough, I jumped out to the database and there were numerous inactive connections hanging around from my application.
I added the following code before the return null statement from the article:
finally {
try {
rs.close();
stmt.close();
c.close();
catch (Exception e) {
System.out.println("after close");
So I need to know the proper procedure to closing the resultset, statement, and connection using a jsf datatable component.You need to make sure you're using the Oracle9i JDBC driver, or using the Oracle 8.1.7.2 JDBC driver as I mentioned above.
If you are using JDeveloper9i release 9.0.2 or 9.0.3, the driver you need is in <jdevhome>\jdbc\lib
Otherwise, you can also download the drivers from OTN. -
Create my own Component ???
When I try to create my own component, I have alway the problem that the components do not resize with setBounds() or something similar. My Component is always shown at the position 4/23 (which depends on the Microsoft Windows Frame-Border-Size with title) and the size of my component is always the full size of the owner-frame.
import java.awt.*;
import java.awt.event.*;
public class MyComponent extends Component implements MouseListener
public MyComponent()
setBounds(30, 30, 64, 64); //this line was ignored
setBackground(Color.white);
public void paint(Graphics g)
g.setColor(Color.black);
g.drawRect(0, 0, 64, 64);
// Mouselistener interface implementation
public void mouseClicked(MouseEvent e) {}
public void mouseEntered(MouseEvent e) {}
public void mouseExited(MouseEvent e) {}
public void mousePressed(MouseEvent e) {}
public void mouseReleased(MouseEvent e) {}
import java.awt.*;
import java.awt.event.*;
class Test extends Frame
public Test()
addWindowListener(new WindowAdapter()
public void windowClosing(WindowEvent e)
dispose();
System.exit(0);
MyComponent m = new MyComponent();
m.setBounds(60, 60, 128, 128); //this line was ignored, too
add(m);
public static void main(String args[])
Test mainFrame = new Test();
mainFrame.setSize(400, 400);
mainFrame.setTitle("Test");
mainFrame.setVisible(true);Well, I believe the setBounds method is used when using Absolute Positioning. See the Swing tutorial on "Using Layout Managers":
http://java.sun.com/docs/books/tutorial/uiswing/layout/index.html
I don't use Frames but I know the default LayoutManager for a JFrame is the BorderLayout. By default any component added to a BorderLayout is placed in the CENTER of the layout and will resize to fill the available size of its container. Again, this information is contained in the above link. -
Tooltip doesn't show with own component
Hello,
I have my own component that paints some rectangles to a
canvas. Now the problem is that I can't see the tooltip over my
object. Here is wat I do
var record:SessionRecord = new SessionRecord();
record.height = TIMELINEHEIGHT;
record.width = data.SESSION_TIME*TIMELINE_SECOND;
record.x =
((data.SESSION_START_SEC*TIMELINE_SECOND)+MARGINLEFT)/2;
record.y = yCanvasPointer/2;
record.toolTip = "blabjdsqodhqhjiouqh";
record.enabled = true;
canvas.addChild(record);
I've implemented the get/set method of the tooltip in my
component class (actionscript class).
public override function get toolTip():String
return this.tooltipText;
public override function set toolTip(value:String):void
this.tooltipText = value;
Anybody any idea ?
Thanks!
Wardquote:
Originally posted by:
Greg Lafrance
The FB3 help topic "About creating advanced components"
mentions the following about Flex components implemtning the
IToolTipManagerClient interface:
IToolTipManagerClient - Indicates that a component has a
toolTip property, and therefore is monitored by the ToolTipManager.
So maybe if you implement this interface you will have
tooptip support.
This is the interface I implemented (specifying the get/set
tooltip methode)... -
Can't instantiate JSF Custom Component
I'm hoping some of you expert (or at least seasoned) JSF custom component developers might be able to lend some insight into the "Can't instantiate class" problem. I have a custom component which extends another component (which happens to be Oracle ADF's panelGroup), and I've verified that everything is in place:
1. Component class uses correct component type referenced by faces-config.xml and tag class
2. Renderer type referenced in faces-config.xml matches that of the renderer type in component class
3. There is a default constructor (no args) for the component class, which also sets the renderer type
4. TLD with tag is correct
All classes are definitely in the classpath, as I have another custom component in the same packages which loads and is used just fine.
Any ideas would be appreciated.
Thanks,
Shawn Bertrand
Tyco ElectronicsSo, is no one else having any problems when using the new JSF components from Java Studio Creator 2 in their existing projects? I can make simple projects in Creator and run them on PointBase and Tomcat and can deploy and run from Eclipse using MyEclipse but I cannot get my existing project working and I am wondering if their is some sort of conflict between the new JSF components and legacy Struts stuff in that project or if perhaps Spring is someone interferering. Kind of at a loss right now...
-
Tooltip on the header of JSF table Component
How to add an Tooltip to the header of the JSF table copmponent?
Please reply....You normally use the HTML 'title' attribute for this. Almost every JSF HTML component also supports it.
-
JSF scroller component Frustration why isn't component rendering in jspx.
Based originally on Sun Microsystem's OWN "Components Demo" this tag library is for the custom
components used in the Virtual Sports Trainer Example Demo. Found inside the book "The Complete Reference JavaServer Faces". Which coincidentally was written by Sun's own Chris Schalk and Ed Burns. I"m having problems getting this component to work (render inside a jspx document). Any insight as to why or how to fix this would be greatly appreciated. And I just want to gain any insight or feedback as to why it's not displaying the t:scroller component. Thats all. I'm displaying the jspx document below a SINGLE jspx document. As I know anything more than 200 lines scares everybody. The cusomtom scroll component/pagination is at the bottom t:scroll. I can only display snippets of the jspx for brevity and the character limit.
<?xml version="1.0" encoding="UTF-8" ?>
<jsp:root version="1.2" xmlns:jsp="http://java.sun.com/JSP/Page"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:t="http://virtualsportstrainer.com/trainercomponents"
xmlns:ui="http://java.sun.com/jsf/facelets">
<jsp:directive.page contentType="text/html;charset=UTF-8"
pageEncoding="UTF-8" />
<jsp:text>
<![CDATA[ <?xml version="1.0" encoding="UTF-8" ?> ]]>
</jsp:text>
<jsp:text>
<![CDATA[ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> ]]>
</jsp:text>
<!-- Custom Scroller Component -->
<t:scroller navFacetOrientation="NORTH" for="eventsTable"
actionListener="#{Main_Backing.processScrollEvent}">
<f:facet name="next">
<h:panelGroup>
<h:outputText value="Next"/>
<h:graphicImage url="/images/arrow-right.gif" />
</h:panelGroup>
</f:facet>
<f:facet name="previous">
<h:panelGroup>
<h:graphicImage url="/images/arrow-left.gif" />
<h:outputText value="Previous" />
</h:panelGroup>
</f:facet>
</t:scroller>
</h:form>
</body>
</html>
</f:view>
</jsp:root>It's being added like this:
PopUpManager.addPopUp(this.whyYouShouldJoinPopup,this,true);
PopUpManager.centerPopUp(this.whyYouShouldJoinPopup);
It's being called inside a Component, not inside the main MXML file. So this is not a reference to the application class, but a component. Is that a problem?
Maybe you are looking for
-
any help would be appreciated
-
Hi In the PO history tab, there is a field called "GR/IR clearing value in local currency". Please advise what is the significance of this field & where does it reflect. If the total value of this field is not zero (e.g. in IR); will there be any pro
-
Hi all, We have come across a problem when the ADRC ADDRNUMBER counter in ERP got full (the standard max limit is 49 999 999). Analysis shows that most of those are empty address rows and created by one-time vendor. In our case the mass of addresses
-
Set English language in other regions
When I first installed Snow Leopard, I selected Italy as region but with english language. As a result, under Language & Text in System Preferences, my region in the Formats was set to "Italy (English)", that is the italian format but with months and
-
Execution method of report created using Web Intelligence
Hi everyone, Could anyone please let me know of the way data in a report created as web intelligence document is refreshed? Is it real-time data each time the report is executed or do I have to explicitly hit the "Refresh" button in order to get late