Tokunbo Oke

Ranch Hand
+ Follow
since Sep 09, 2003
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by Tokunbo Oke

Tim Holloway, thanks for your response. You are absolutely correct my rendered setting are lost because of the fact that the backing bean is request scoped.

Regarding the visible URL that changes when I am not using redirect to navigate to another page (or even to the same page); are you saying this is a normal behaviour of JSF? If yes, please give me a link to any document that sheds more light on why this is the case. I am just curious to know why it is designed to work this way, as this is different from what I understand about forwarding and redirecting.

Thanks.
13 years ago
JSF
Guy deLyonesse, thanks for your response.

I do not have any problem navigating from the menu form to the status form, though. This is because I am using JSF 2.0'S implicit navigation, which is an alternative to declaring navigation rules in faces-config.xml. The only thing I need help with is understanding why the URL changes when I submit the status form and I am not redirecting?

Thanks.
13 years ago
JSF
In order to get to the menu form I enter http://localhost:8080/myapp/pages/menu.jsf into the browser. When the menu form comes up, I click on a button that takes me to the status form. After getting to the status form, the URL remains the same i.e http://localhost:8080/myapp/pages/menu.jsf However, as soon as I click any button in the status form, the URL changes (to http://localhost:8080/myapp/pages/status.jsf ). As a result of this, all the components that have been programmatically set to rendered=false become rendered when the status form is rendered after submission.

Even though I did not specify a redirect, the changing of the URL gives the impression that a redirect takes place after the status form is submitted. Can anyone please tell me why this is happening and how I can stop it. I am using MyFaces 2.0 on Tomcat 7 The managed bean for status form is in the request scope.

Thanks.


1. A button in the status form that changes the URL
====================================================


2. Part of status form's managed bean
====================================


2. Faces Config
================

13 years ago
JSF
When a user clicks an option box, I want to set the value of a field in the current row to "OR". I know how to get the current row from the the dataTable.

NOte:
The backing bean in which I set the new value of the field is in the request scope.

Problem
=======
After setting the value of the relevant row to "OR" (via a backing bean) "OR" is not reflected in the data table i.e in the browser, the value of all fields in the data table remain unchanged.

Please tell me what I need to do in order to get my changes reflected in the UI.

Do I need to add the edited row via the datamodel of the data table i.e. via setWappedData method? It is not a new row, just an edited one.


The code in Which I am setting "OR"
===================================

Object selectedRow = this.getCustomerUiTable().getRowData();
if (selectedRow instanceof CustomerBean) {
CustomerBean selectedCustomerBean = (CustomerBean) selectedRow;
//If this attribute has been selected...
if (selectedCustomerBean.isAttributeSelected()) {
selectedCustomerBean.setBooleanCond("OR");
}
}

Thank you.
14 years ago
JSF
Getting the relevant backing bean (backing bean of form B) from the relevant scope and updating the relevant properties, made it possible to achieve my goal. Once again, thanks a lot Tim.
14 years ago
JSF
Thank you very much for your response.

Your JSF related comments reflects what my research has also indicated i.e. that I should get the relevant bean from the relevant scope and then update the relevant properties.

I will post an update after experimenting.

14 years ago
JSF
If two forms appear in the same screen (JSP/JSF file) say forms A and B, can a button on form A, populate the fields of form B via JSF lifecycle?

Form B works well i.e. it gets populated with data when its action method is called from a button attached to it (form B), but not when the form B's action method is called from a backing bean method of form A.

Please note, although the forms are in the same screen each form has a separate backing bean.

Please tell me how to get this to work.

Thanks
14 years ago
JSF
I have a JSF screen (jsp/jsf file) that is made up of a tree and four forms. The tree is always rendered (visible) while Only one form is rendered at a time. So the tree and anyone of the forms is visible at any point in time.
The tree node that is clicked determines which form is rendered. When a node of the tree is clicked, a method is called from the backing bean of the tree. The methodis suppoded to both render the tree and the form, and populate the form with data.

Problem
=======
The each form gets rendered, but they are never populated with data. I know the form and methods are functioning well, because when I call the action methods from a value bound button that is attached to the form, the form gets populated with data. i.e. each form works very well (gets populated with data) when the method is called from a button attached to the form, but not when the method is called via a tree node and the tree's backing method.

Help
====
Please tell me how to populate the fields of the form when it is sharing a screen with the tree. Please note, the clicking of a node of the tree is the trigger.

To put my question another way, if two forms appear in the same screen (JSP/JSF file) say forms A and B, can a button on form A, populate the fields of form B via JSF lifecycle? The answer to this will enable me to work out how the tree/form case can be made to work.

Please note, although the tree and the forms are in the same screen each form has a separate backing bean.

Thanks
14 years ago
JSF
Thanks for your response. As a work around, I have used IceFaces stackedPanel.
14 years ago
JSF
I want to create a screen that works very much like "windows explorer". The screen is to be divided into 2 panels. The left panel

will contain a tree. When the user clicks on a node in the tree, I want to render the relevent form, in the right hand panel.

Please note, each tree node renders a different form.

Please tell me how to render different forms (one at a time) in the same position (same coordinates) on the right hand panel.

Should I stack the forms on top of each other at design time and set "rendered" property to false, then set the relevant form to

rendered when the user clicks a node?

Also, please tell me the best component to use in order to render a screen with 2 columns - very much like "windows explorer".

I have already got the tree working.

Thank you.
14 years ago
JSF
You did not show your source code. Nevertheless, I suggest that you look into COMPONENT BINDING.
15 years ago
JSF
After submission, status.jsp goes through all phases successfully, but never enters/executes the action method i.e. #{statusManagedBean.createStatusAction}, can anyone please suggest any reason that could be the cause.

Please see code below:

JSF - status.jsp
================
<%@ page language="java" contentType="text/html;charset=UTF-8"%>
<%@ taglib prefix="f" uri="http://java.sun.com/jsf/core"%>
<%@ taglib prefix="h" uri="http://java.sun.com/jsf/html"%>
<f:loadBundle basename="com.fujimitsu.moneytransfer.resources.UIResources" var="bundle"/>
<html>
<f:view>
<head>
<title><h:outputText value="#{bundle.registerStatus}"/> </title>
<link href="../css/stylesheet.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<f:verbatim><p>JavaServer Faces Page</p>
<p>
</p><table border="0" cellpadding="0" cellspacing="0" width="800">
<tr>
<td>
<h:graphicImage url="/images/resources.jpg" alt="#{bundle.img_alt_info}"/>
</td>
</tr>

<tr>
<td>
<h:messages globalOnly="false" styleClass="validationMessage" layout="table"/>
<p>
<h:form id="statusManagedBeanForm">
<h:panelGrid columns="3">
<h:outputText value="#{bundle['statusField.status']}"/>
<h:inputText id="status" value="#{statusManagedBean.status}"/>
<h:message for="status" styleClass="validationMessage"/>
<h:outputText value="#{bundle['statusDescField.statusDesc']}"/>
<h:inputText id="statusDesc" value="#{statusManagedBean.statusDesc}"/>
<h:message for="statusDesc" styleClass="validationMessage"/>
<h:outputText value="Created By:"/>
<h:inputText id="createdBy" binding="#{statusManagedBean.createdBy}"/>
<h:message for="createdBy" styleClass="validationMessage"/>
</h:panelGrid>
<h:commandButton action="#{statusManagedBean.createStatusAction}" type="submit" value="Submit"/>
</h:form>
</p>
</td>
</tr>
</table>

</f:verbatim>

</body>
</f:view>
</html>




HTML code of status.jsp before the submit button is clicked
===========================================
<form id="statusManagedBeanForm" name="statusManagedBeanForm" method="post" action="/moneytransferFaces/pages/status.jsf" enctype="application/x-www-form-urlencoded">
<input type="hidden" name="statusManagedBeanForm" value="statusManagedBeanForm" />
<table>
<tbody>
<tr>
<td>Status</td>
<td><input id="statusManagedBeanForm:status" type="text" name="statusManagedBeanForm:status" /></td>
<td></td>
</tr>
<tr>
<td>Status Desc</td>
<td><input id="statusManagedBeanForm:statusDesc" type="text" name="statusManagedBeanForm:statusDesc" /></td>
<td></td>
</tr>
<tr>
<td>Created By:</td>
<td><input id="statusManagedBeanForm:createdBy" type="text" name="statusManagedBeanForm:createdBy" /></td>
<td></td>
</tr>
</tbody>
</table>
<input type="submit" name="statusManagedBeanForm:j_id_jsp_948632549_16" value="Submit" /><input type="hidden" name="javax.faces.ViewState" id="javax.faces.ViewState" value="j_id4:j_id5" />
</form>





HTML code of status.jsp after the submit button is clicked
==========================================
Please note: action="/moneytransferFaces/pages/status.jsf" , is this what it is supposed to be?
<form id="statusManagedBeanForm" name="statusManagedBeanForm" method="post" action="/moneytransferFaces/pages/status.jsf" enctype="application/x-www-form-urlencoded">
<input type="hidden" name="statusManagedBeanForm" value="statusManagedBeanForm" />
<table>
<tbody>
<tr>
<td>Status</td>
<td><input id="statusManagedBeanForm:status" type="text" name="statusManagedBeanForm:status" /></td>
<td></td>
</tr>
<tr>
<td>Status Desc</td>
<td><input id="statusManagedBeanForm:statusDesc" type="text" name="statusManagedBeanForm:statusDesc" /></td>
<td></td>
</tr>
<tr>
<td>Created By:</td>
<td><input id="statusManagedBeanForm:createdBy" type="text" name="statusManagedBeanForm:createdBy" /></td>
<td></td>
</tr>
</tbody>
</table>
<input type="submit" name="statusManagedBeanForm:j_id_jsp_948632549_16" value="Submit" /><input type="hidden" name="javax.faces.ViewState" id="javax.faces.ViewState" value="j_id1:j_id3" />
</form>


STATUS BEAN
===========
package com.fujimitsu.moneytransfer.beans;

import javax.faces.component.html.HtmlInputText;

public class Status {
private String status;
private String statusDesc;
private HtmlInputText createdBy;

public Status() {
}

public HtmlInputText getCreatedBy() {
return createdBy;
}

public void setCreatedBy(HtmlInputText createdBy) {
this.createdBy = createdBy;
}

public String getStatus() {
return status;
}

public void setStatus(String status) {
this.status = status;
}

public String getStatusDesc() {
return statusDesc;
}

public void setStatusDesc(String statusDesc) {
this.statusDesc = statusDesc;
}

public String createStatusAction() {
this.setStatusDesc("testing createStatusAction()...");

return "success";
}

}




FACES CONFIG
============
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright 2003 Sun Microsystems, Inc. All rights reserved.
SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
-->
<!DOCTYPE faces-config PUBLIC
"-//Sun Microsystems, Inc.//DTD JavaServer Faces Config 1.0//EN"
"http://java.sun.com/dtd/web-facesconfig_1_0.dtd">

<faces-config>
<application>
<locale-config>
<default-locale>en</default-locale>
</locale-config>
</application>
<managed-bean>
<managed-bean-name>statusManagedBean</managed-bean-name>
<managed-bean-class>
com.fujimitsu.moneytransfer.beans.Status
</managed-bean-class>
<managed-bean-scope>session</managed-bean-scope>
</managed-bean>
<navigation-rule>
<from-view-id>/pages/status.jsf</from-view-id>
<navigation-case>
<from-outcome>success</from-outcome>
<to-view-id>/pages/home.jsf</to-view-id>
</navigation-case>
</navigation-rule>
<navigation-rule>
<from-view-id>/pages/status.jsp</from-view-id>
<navigation-case>
<from-outcome>success</from-outcome>
<to-view-id>/pages/home.jsp</to-view-id>
</navigation-case>
</navigation-rule>
<lifecycle>
<phase-listener>
com.fujimitsu.moneytransfer.utils.PrintTreePhaseListener
</phase-listener>
</lifecycle>
</faces-config>


web.xml
======
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE web-app PUBLIC
"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>

<!--A short name that is intended to be displayed by tools.-->
<display-name>The simplest JSF application.</display-name>
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>/faces/*</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.jsf</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.faces</url-pattern>
</servlet-mapping>

</web-app>

DIRECTORY STRUCTURE
====================
appName
pages
WEB-INF
.........
.........

Thanks.
16 years ago
JSF
I have both books as well, however, I find Core Java Server Faces to be a better introductory book. I was so impressed with the book that I ended up buying both Core Java I and Core Java II (co written by one of the authors of Core Java Server Faces).

Gambatte kudasai.
18 years ago
JSF
Thank you, I will not try it out. Also thanks for the advise
19 years ago
JSP