FB4 DataGrid - ArrayList changes not persistent
I made a small test app to show the problem:
<?xml version="1.0" encoding="utf-8"?>
<s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
creationComplete="creationCompleteHandler( event )" >
<fx:Script>
<![CDATA[
import mx.collections.ArrayList;
import mx.events.CollectionEvent;
import mx.events.FlexEvent;
// >>>>> Variables <<<<<
[Bindable]
private var _mainData:ArrayList;
// >>>>> Event Handlers <<<<<
protected function creationCompleteHandler( event:FlexEvent ):void
_mainData = new ArrayList();
_mainData.addItem( new TestValueObject( false ) );
_mainData.addItem( new TestValueObject( true ) );
_mainData.addEventListener( CollectionEvent.COLLECTION_CHANGE, dataChange );
private function dataChange( event:CollectionEvent ):void
if( event.items[ 0 ].oldValue != event.items[ 0 ].newValue ) {
// ToDo: update value on server
var justForBreakpoint:uint = 1;
]]>
</fx:Script>
<mx:DataGrid dataProvider="{ _mainData }"
editable="true"
textAlign="center"
horizontalCenter="0" >
<mx:columns>
<mx:DataGridColumn dataField="active"
headerText="Active"
width="50"
draggable="false"
editable="true"
itemRenderer="CheckBoxRenderer"
rendererIsEditor="true" />
<mx:DataGridColumn dataField="active"
headerText="value"
width="50"
draggable="false"
editable="false" />
</mx:columns>
</mx:DataGrid>
</s:WindowedApplication>
The Value Object:
package
[Bindable]
public final class TestValueObject
// >>>>> Variables <<<<<
public var active:Boolean;
// >>>>> Constructor <<<<<
public function TestValueObject( itemActive:Boolean )
active = itemActive;
The CheckBox ItemRenderer:
<?xml version="1.0" encoding="utf-8"?>
<s:MXDataGridItemRenderer xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
focusEnabled="true">
<s:CheckBox id="cb"
selected="{ data.active }"
change="data.active = cb.selected"
horizontalCenter="0"/>
</s:MXDataGridItemRenderer>
The Boolean value in the value object changes permanently only from true to false but not vice versa.
The value of true only stays as long as its DataGrid row is selected. When highlighting the other row, it flips back to false.
How do I get this item renderer to function properly?
Thanks,
David
<?xml version="1.0" encoding="utf-8"?>
<s:MXDataGridItemRenderer xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
focusEnabled="true" creationComplete="mxdatagriditemrenderer1_creationCompleteHandler(event)">
<fx:Script>
<![CDATA[
import mx.events.FlexEvent;
protected function mxdatagriditemrenderer1_creationCompleteHandler(event:FlexEvent):void
// TODO Auto-generated method stub
cb.selected=data.active;
]]>
</fx:Script>
<s:CheckBox id="cb"
click="data.active=cb.selected"
horizontalCenter="0"/>
</s:MXDataGridItemRenderer>
With these changes in CheckBoxRenderer, I was able to get the functionality you had described. I used this logic. Whenever , the checkbox is clicked, selected is toggled. and then active can be assigned accordingly. Also, since The value object is bindable, selected ={data.active} would change the value of selected which is not something you might find useful. In my opinion the changed value of selected(on click) should be used rather than trying to change it's value.
Hope this helps
Nishad
Similar Messages
-
W520 UEFI boot order changes not persistent
I have had a W520 for the entire summer. I have always double or triple booted my laptops because of the nature of my work, but this is the first system I have ever owned with UEFI.
The problem: the W520 BIOS/Firmware/UEFI or whatever you want to call it does not keep the GPT boot order of the OS's that I attempt to save. When I reboot and go back to the BIOS after saving it, it is in the same order that I started, which is in fact, the order that I installed the operating systems that, starting with the last one that I installed, first. I called up Lenovo tech support and very quickly they conveyed to me that Lenovo only supports single boot of the operating system that came bundled with the installation.
I thought a later BIOS would help. No such luck.
As much as I have read about UEFI, I know that the boot order is stored in the UEFI NVRAM. There are some third-party utils that can edit the NVRAM configuration, but I was not able to find a cookbook guide clear enough wear I was OK messing with the health of my well populated analysis workstation. If anyone has any experience with a step-by-step solution, I would be interested in hearing, and even paying, for your expertise as needed.
Thanks in advance
W520 CTO BIOS rev 1.37. Core i7-2760QM, 32GB PC3-10600, NVidia Quadro 1000M, Samsung 830 512GB, SanDisk pSSD-S2 32GB, x64 tri-boot: Win2k8R2, Fedora 17, Ubuntu 12.04Hi,
It doesn't change the boot order, it create a new item "boot from file".
Are you using a virtual machine or physical machine?
If you are using a virtual machine, you can change the boot order from hyper-v settings.
If you are using a physical machine, you need to change the boot order manually.
We
are trying to better understand customer views on social support experience, so your participation in this
interview project would be greatly appreciated if you have time.
Thanks for helping make community forums a great place. -
I have imported an mp3 to my Library. I want to keep it as media kind = podcast but no matter how often I change the tag in get info > options > media kind, the change will not persist, and the file remains in my Music list not my Podcast list.
Resolved in update.
-
Changes do not persists to DB?
Hi all,
I managed to configure coherence but changes that I made do not persists to DB?
My cache-config.xml:
<?xml version="1.0"?>
<!DOCTYPE cache-config SYSTEM "cache-config.dtd">
<cache-config>
<caching-scheme-mapping>
<cache-mapping>
<cache-name>*</cache-name>
<scheme-name>distributed-eclipselink</scheme-name>
</cache-mapping>
</caching-scheme-mapping>
<caching-schemes>
<distributed-scheme>
<scheme-name>distributed-eclipselink</scheme-name>
<service-name>EclipseLinkJPA</service-name>
<serializer>
<class-name>oracle.eclipselink.coherence.integrated.cache.WrapperSerializer</class-name>
</serializer>
<backing-map-scheme>
<read-write-backing-map-scheme>
<internal-cache-scheme>
<local-scheme/>
</internal-cache-scheme>
<!-- Define the cache scheme -->
<cachestore-scheme>
<class-scheme>
<class-name>oracle.eclipselink.coherence.integrated.EclipseLinkJPACacheStore</class-name>
<init-params>
<init-param>
<param-type>java.lang.String</param-type>
<param-value>{cache-name}</param-value>
</init-param>
<init-param>
<param-type>java.lang.String</param-type>
<param-value>HRPU</param-value>
</init-param>
</init-params>
</class-scheme>
</cachestore-scheme>
</read-write-backing-map-scheme>
</backing-map-scheme>
<autostart>true</autostart>
</distributed-scheme>
</caching-schemes>
</cache-config>I'm trying to use TopLink Grid Cache Configuration.
Thanks in advance.Ah. I missed that. If you are using container managed transactions then you need to change from RESOURCE_LOCAL to JTA and set the target-server property. You also need a JTA datasource. Here's an example from http://wiki.eclipse.org/EclipseLink/Examples/JPA/WebLogic_Web_Tutorial#JTA_Datasource
Note that in an EE application there is no need to list your classes.
<persistence version="1.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd">
<persistence-unit name="example" transaction-type="JTA">
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
<jta-data-source>OracleDS</jta-data-source>
<properties>
<property name="eclipselink.target-server" value="WebLogic_10"/>
<property name="eclipselink.logging.level" value="FINEST"/>
</properties>
</persistence-unit>
</persistence>--Shaun -
Changes not being saved in Address Book
Hi,
I've been editing one of the entries in my Address Book (deleting the surname input), but every time I do this and go out of Address Book the surname comes back. Not a massive problem, but it's very annoying especially as it all links in to Mail etc.
If anyone knows why this is and how it can be fixed it would be much appreciated.
Thanks in advance.I just encountered the same thing while setting up a couple new Macs with 10.6.8, it's very frustrating, but I found the solution, at least in my case. Maybe this is the same problem you are encountering:
I imported a whole bunch of contacts from another Mac to the first one (using a batch vCard). Anyway, I noticed a few of them were out of date so I edited them. Then I saved them (using both the export vCard group and the Address Book archive), then I took that file to the second Mac I was setting up, and imported them. but I noticed that most (but not all) of the changes I'd just made (prior to exporting) were not saved. This was quite a puzzler, and took a little while to figure out why some changes were being saved and not others.
I believe this problem is due to a interface design flaw in Address Book.
You see, when you press the "Edit" button to unlock a contact record, the "edit" button turns blue (signifying that the record is editable). But what's not clear is that none of the changes are actually committed until you press the exact same "Edit" button again to commit all the changes you've made (on that record and any others edited since the "Edit" button was last clicked).
So, really, what's missing here is a warning dialog. When you select an Export option, and the "edit" button is still blue, a dialog should appear saying that "recent changes are unsaved and will be lost" (or something to that effect). In my opinion, the edit button should probably turn into a "Save Changes" button or something like that.
This is especially confusing, because the uncommitted changes are persistently visible in the Address Book even after switching contacts. In most databases, uncomitted changes are lost as soon as you leave a record without saving, but not in Address Book. It looks like all your changes have been made even though they aren't. And I think it's fair to say that the typical user will assume that when you export the address book contacts, the export will appear identical to how it appeared when they saved it, but if the "Edit" button was blue during the save, that will not be the case, and there is no warning to that effect. So it leads to unexpected behavior in that some recent changes are saved but the most recent are not.
Anyway, I'm sure there'll be other opinions as to the interface design, but it's clear to me this is the problem, and the solution is to always make sure the "edit" button is NOT blue before saving or exporting the address book or contacts.
I also wouldn't have noticed it unless I was trying to set up two computers at once (since the changes were so minor, I might have not ever noticed they weren't saved otherwise). So I wouldn't be surprised if this problem has been around for a long time and I never noticed it before.
Hope that helps... -
Spark Datagrid Selection change Event
starting to work with the spark datagrid.
I want to send off a web service using the values of a row right after they get done editing the row and leave it.
No more change event that I can see like MX and gridItemEditorSessionSaveHandler kicks on every tab between cells
if I use event.currentTarget.selectedItem
Selection Change gives me the new row.
Selection Changing only kicks with mouse row changes not tabs
Suggestions?
I want to register the row with both mouse (on a numeric stepper) and tab(for text fields) events.
Thanks
Dan PrideHi Dan,
Try valueCommit event handler, but I'm not 100% sure that is triggered upon dataProvider data changes.
Another way is to listen for changes in the dataProvider variable. -
RoomExtension: Room manipulation (parameters) not persistent
Hi Folks,
im going crazy with RoomExtensions.
(ExtensionPoint: ON_CREATE_ROOM)
I get the actual Room via the IRoomInfoReader.
If I change for example the description - everything is fine. (I enter the room - and the description is changed)
BUT: If I add parameters (via IRoom.addParameter()) - I see the changes in the extension afterwards, but its not persistent. When I enter the room, the parameters are gone. How can this be?
Held would be VERY appriciated!
Thanks,
SimonHi Detlev,
thanks for your response!
You are completely right, the exact name is addRoomParameter().
The code from the process method of my extension. As the logfile shows: The parameters are added (the result is always
true
and the
getAllParamsNames()
shows all parameters(in the extension).
But when I enter the room, the parameters are gone.
And it is definitely the same room - I double checked the room-ID.
IRoomInfoReader roomInfoReader =
(IRoomInfoReader) context.getOptionalValue(PARAMETER2_ID);
log.println("Inforeader from context: " + roomInfoReader.toString());
String l_roomID = roomInfoReader.getId();
log.println("RoomID: " + l_roomID);
log.println("RoomDesc: " + roomInfoReader.getDescription());
boolean param1_success;
boolean param2_success;
IRooms roomsAPI = (IRooms) PortalRuntime.getRuntimeResources().getService(IRooms.PORTAL_SERVICE_ID);
try {
IRoom this_room = roomsAPI.getRoom(l_roomID);
// TODO: handle partial projects differently
log.println("EXTENSION: Parameterschleife (2!!)");
String[] allparams = this_room.getAllRoomParameterNames();
String paramname;
for (int i=0; i< allparams.length; i++){
paramname = allparams<i>;
log.println("EXTENSION: Raumparameter vor Anlage (neue Vorlage): " + paramname);
IRoomParameterValue l_parameter_wf =
TemplateDataFactory.createRoomParameterValue(
Workflow.WorkflowDynPage.ROOM_PARAM_WF,
"Workflowstate",
"3",
false);
IRoomParameterValue l_parameter_name =
TemplateDataFactory.createRoomParameterValue(
Workflow.WorkflowDynPage.ROOM_PARAM_WFNAME,
"Name of current Cycle",
"Name of Cycle not yet set",
false);
IRoomParameterValue l_parameter_dum =
TemplateDataFactory.createRoomParameterValue(
"Dummy",
"Proof of concept",
"could be working",
false);
param1_success = this_room.addRoomParameter(l_parameter_wf);
param2_success = this_room.addRoomParameter(l_parameter_name);
this_room.addRoomParameter(l_parameter_dum);
allparams = this_room.getAllRoomParameterNames();
if (allparams != null){
// for (int index=0; i<allParams.length; index++){
// debug += allParams[index];
List l = Arrays.asList(allparams);
Iterator it = l.iterator();
while (it.hasNext())
log.println ( (String) it.next());
else{
log.println( "kein Param vorhanden");
log.println( "Param adding. State: " + String.valueOf(param1_success) + " Name: " + String.valueOf(param2_success)) ;
} catch (RoomInstantiationException e) {
log.println(
new java.util.Date() + ": " + "Room Instanciation failed. RoomID: " + l_roomID);
e.printStackTrace();
error = true;
finally
log.println(
new java.util.Date() + ": " + "finished processing Extension");
log.close(); -
[SOLVED] netcfg static IP not persisting across reboots in VM
I ran into an issue with netcfg static IP not persisting across reboots in a VM. I figured it out, but it took me awhile as a brand new user, so I thought I'd post it.
Setup
Using VMWare Workstation 8.0.3 build-703057 with bridged networking
Host OS: Linux Mint 14 64-bit
Guest OS: Arch Linux 2013.03.01 x86_64
Given a fresh install on the guest, setup netcfg:
cd /etc/network.d
cp examples/ethernet-static ./myprofile
nano myprofile
# customize this file. I also added NETMASK='255.255.255.0'
systemctl enable netcfg@myprofile
systemctl start netcfg@myprofile
Test the configuration. It should be successful:
ping google.com
Problem
See if the changes survive a reboot.
reboot
ping google.com
I got the error "connect: Network is unreachable".
Check the logs:
journalctl
G
I found the following netcfg failure..
[email protected]: main process exited, code=exited, status=1/FAILURE
..prior to the following device initialization:
kernel: e1000 0000:02:00.0 eth0: Intel(R) PRO/1000 Network Connection
system-udevd[117]: renamed network interface eth0 to emp2s0
Solution
It looks like netcfg is being started before the device it depends on has been initialized. Inform systemd of the
dependency so they start in the proper order:
# nano /etc/systemd/system/multi-user.target.wants/[email protected]
# Add the following to [Unit]. Remember to replace enp2s0 with your device name.
Requires=sys-subsystem-net-devices-enp2s0.device
After=sys-subsystem-net-devices-enp2s0.device
Test again:
reboot
ping google.com
This should now be successful.fukawi2 wrote:
$ man netcfg-profiles wrote:
Miscellaneous options
IPCFG
Array of arguments to pass to ip. The power of this options is
that it allows both simple and complicated routing
configurations, within the framework of netcfg.
SKIPNOCARRIER
‘yes’/‘no’. Don’t abort interface setup if no carrier is
found.
Thank you, [Solved]. -
"Open With" is not persistent for Numbers
Depsite my best efforts to avoid installing the new iWork apps, OS X defeated me.
Now, I want to set the files to "Open With..." the iWork '09 versions. I have gone thru the typical Change All procedure, but these changes are not persistent.
I am insanely frustrated with the behavior, that is compounding my frustration over the new iWork apps with poor functionality compared to the brilliant iWork '09 apps.
Any advice? ...for my OS X issue
Thank you, ChuckDo you have KM configured within the EP System? Make sure the user has the Business Interlligence role also.
-
User profile images not persisting after log off on Server 2012 R2 RDS Session Hosts
Hi,
We have a 2012 R2 remote desktop deployment, with two session collections, a gateway server, and connection broker.
We have set these session collections to use centralised user profile disks.
What I am having an issue with, is that when a user sets their profile image through the server they have logged on to (I have the desktop experience pack installed so they are able to do this), they can see the user tile has been set with that image in
settings and also on the start menu, but as soon as they log off the server and back on, their profile image has been reset to the default blank image.
I have checked all of my group policy options, and cannot find any settings that could be impacting this.
Does anyone have any ideas why these images are not persisting for users or admins?
Thanks, EdsPlease check that the user is not getting a temporary profile each time he logs in. Also, make sure that the RDP client is properly configured to display the Wallpaper: http://www.webapper.com/blog/index.php/2007/10/18/enabling-desktop-wallpaper-on-remote-desktop-terminal-services/
This posting is provided "AS IS" with no warranties or guarantees , and confers no rights.
Get Active Directory User Last Logon
Create an Active Directory test domain similar to the production one
Management of test accounts in an Active Directory production domain - Part I
Management of test accounts in an Active Directory production domain - Part II
Management of test accounts in an Active Directory production domain - Part III
Reset Active Directory user password -
Email address change not showing on ipad after sync
iTunes email address change not showing on ipad after sync
So change it.
Open iTunes, scroll to the bottom of the main page, tap your account name, log out then sign in with the correct name. -
EJB 3.0 - JSF APPLICATION: DATA DOES NOT PERSIST TO THE DATABASE
Hi,
I am developing a JSF - EJB application and the data that I send from JSP Page through JSF Managed Bean --> Session Bean --> Java Persistence does not persist in database.
Here is my scenario ( Iam using JDeveloper IDE to create this application) -
SCENARIO START
The scenario consists of two web pages, one enlisting all the users stored in the database, the other contains a form for adding a user
1.) INDEX.JSP
2.) ADDUSER.JSP
Step 1: Create the USERS Table in database
CREATE TABLE users
user_id serial,
username varchar(255) NOT NULL,
first_name varchar(255),
last_name varchar(255),
password char(64) NOT NULL,
CONSTRAINT pk_users PRIMARY KEY (user_id)
Step 2: Add Database Connection To JDeveloper
Go to Database Connection Navigator and create a New Database Connection using the Wizard
Step 3: Create a New Application in JDeveloper and select JSF, EJB from Application Template
Step 4: ENTITY BEAN - In the EJB Node Right Click and Select EJB à New Entites from Table (JPA/EJB3.0)
Use The Wizard and create Entity Bean from Users Table which creates an Entity Bea POJO file as follows –
User.java -
package lux.domain;
import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQuery;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
@Entity
@NamedQuery(name = "User.findAll", query = "select o from User o")
@Table(name = "USERS")
public class User implements Serializable {
@Column(name="FIRST_NAME")
private String firstName;
@Column(name="LAST_NAME")
private String lastName;
@Column(nullable = false)
private String password;
@Column(nullable = false)
private String username;
@Id
@GeneratedValue(strategy=GenerationType.SEQUENCE, generator="users_seq_generator")
@SequenceGenerator(name="users_seq_generator", sequenceName="users_user_id_seq")
@Column(name="USER_ID", nullable = false)
private Long userId;
public User() {
public String getFirstName() {
return firstName;
public void setFirstName(String firstName) {
this.firstName = firstName;
public String getLastName() {
return lastName;
public void setLastName(String lastName) {
this.lastName = lastName;
public String getPassword() {
return password;
public void setPassword(String password) {
this.password = password;
public String getUsername() {
return username;
public void setUsername(String username) {
this.username = username;
public Long getUserId() {
return userId;
public void setUserId(Long userId) {
this.userId = userId;
Step 5: STATELESS SESSION BEAN - In the EJB Node Right Click and Select EJB à New Entites from Table (JPA/EJB3.0)
Again Right Click on Model and create Session Bean from Wizard which creates two files –
UserDAOBean.java – Stateless Session Bean
UserDAO.java – Local Interface
package lux.facade;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;
import lux.domain.User;
@Stateless(name="UserDAO")
public class UserDAOBean implements UserDAO {
@PersistenceContext(unitName="Model")
private EntityManager em;
public UserDAOBean() {
public User getUser(int UserId) {
User u = new User();
u = em.find(User.class, UserId);
return u;
public List<User> getAllUsers() {
Query q = em.createQuery("SELECT u FROM User u");
List<User> users = q.getResultList();
return users;
public void createUser(User u) {
String hashedPw = hashPassword(u.getPassword());
u.setPassword(hashedPw);
em.persist(u);
public void updateUser(User u) {
String hashedPw = hashPassword(u.getPassword());
u.setPassword(hashedPw);
em.merge(u);
public void deleteUser(User u) {
em.remove(u);
private String hashPassword(String password) {
StringBuilder sb = new StringBuilder();
try {
MessageDigest messageDigest = MessageDigest.getInstance("SHA");
byte[] bs;
bs = messageDigest.digest(password.getBytes());
for (int i = 0; i < bs.length; i++) {
String hexVal = Integer.toHexString(0xFF & bs);
if (hexVal.length() == 1) {
sb.append("0");
sb.append(hexVal);
} catch (NoSuchAlgorithmException ex) {
Logger.getLogger(UserDAOBean.class.getName()).log(Level.SEVERE, null, ex);
return sb.toString();
Step 6: Create a Deployment file in the Model and Deploy this to a JAR file
Step 7: Now Right Click on View/Controller Node and create a Java File –
UserController.java -
package lux.controllers;
import javax.ejb.EJB;
import javax.faces.model.DataModel;
import javax.faces.model.ListDataModel;
import lux.domain.User;
import lux.facade.UserDAO;
public class UserController {
@EJB UserDAO userDao;
private User user;
private DataModel model;
public String createUser() {
this.user = new User();
return "create_new_user";
public String saveUser() {
String r = "success";
try {
userDao.createUser(user);
} catch (Exception e) {
e.printStackTrace();
r = "failed";
return r;
public DataModel getUsers() {
model = new ListDataModel(userDao.getAllUsers());
return model;
public User getUser() {
return user;
public void setUser(User user) {
this.user = user;
Step 8: Configure page flow in faces-config.xml
1. Create the JSP file adduser.jsp by right-clicking View-Controller
node and selecting New > JSP. Use the wizard to create JSF – JSP Page, fill in
File Name adduser.jsp, click Finish. -
<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>
<%@taglib prefix="f" uri="http://java.sun.com/jsf/core"%>
<%@taglib prefix="h" uri="http://java.sun.com/jsf/html"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>New user</title>
</head>
<body>
<f:view>
<h:form>
<h:messages/>
<h:panelGrid columns="2">
<h:outputText value="Username"/>
<h:inputText
id="Username"
value="#{user.user.username}"
required="true"/>
<h:outputText value="First name"/>
<h:inputText
id="FirstName"
value="#{user.user.firstName}" />
<h:outputText value="Last name"/>
<h:inputText
id="LastName"
value="#{user.user.lastName}" />
<h:outputText value="Password" />
<h:inputSecret
id="Password"
value="#{user.user.password}"
required="true" />
<h:panelGroup/>
<h:commandButton
action="#{user.saveUser}"
value="Save"/>
</h:panelGrid>
</h:form>
</f:view>
</body>
</html>
2. Repeat the previous step for another JSP file failed.jsp.
3. On failed.jsp add the string
Save failed
Next we configure the page flow.
1. Open faces-config.xml.
2. Create index.jsp -
<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>
<%@taglib prefix="f" uri="http://java.sun.com/jsf/core"%>
<%@taglib prefix="h" uri="http://java.sun.com/jsf/html"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>User Listing</title>
</head>
<body>
<f:view>
<h:form>
<h:outputText value="User Listing"/>
<h:commandLink action="#{user.createUser}" value="Create a user"/>
<h:dataTable value="#{user.user}"
var="dataTableItem" border="1" cellpadding="2" cellspacing="2">
<h:column>
<f:facet name="header">
<h:outputText value="Username"/>
</f:facet>
<h:outputText value="#{dataTableItem.username}" />
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="First name"/>
</f:facet>
<h:outputText value="#{dataTableItem.firstName}" />
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="Last name"/>
</f:facet>
<h:outputText value="#{dataTableItem.lastName}" />
</h:column>
</h:dataTable>
</h:form>
</f:view>
</body>
</html>
3. Drag an arrow from index.jsp to adduser.jsp and replace the arrow’s label to create_new_user.
4. Repeat the previous step for failed, by dragging and arrow from adduser.jsp to failed.jsp renaming the label to f
ailed
5. Finally repeat the step for adduser.jsp, by dragging from adduser.jsp to index.jsp renaming the label to success.
This creates the following faces-config.xml file –
<?xml version='1.0' encoding='UTF-8'?>
<faces-config>
<managed-bean>
<managed-bean-name>user</managed-bean-name>
<managed-bean-class>lux.controllers.UserController</managed-bean-class>
<managed-bean-scope>session</managed-bean-scope>
<managed-property>
<property-name>username</property-name>
<value>#{username}</value>
</managed-property>
<managed-property>
<property-name>firstName</property-name>
<value>#{firstName}</value>
</managed-property>
<managed-property>
<property-name>lastName</property-name>
<value>#{lastName}</value>
</managed-property>
<managed-property>
<property-name>password</property-name>
<value>#{password}</value>
</managed-property>
</managed-bean>
<navigation-rule>
<from-view-id>/index.jsp</from-view-id>
<navigation-case>
<from-outcome>create_new_user</from-outcome>
<to-view-id>/adduser.jsp</to-view-id>
</navigation-case>
</navigation-rule>
<navigation-rule>
<from-view-id>/adduser.jsp</from-view-id>
<navigation-case>
<from-outcome>failed</from-outcome>
<to-view-id>/failed.jsp</to-view-id>
</navigation-case>
<navigation-case>
<from-outcome>success</from-outcome>
<to-view-id>/index.jsp</to-view-id>
</navigation-case>
</navigation-rule>
</faces-config>
Step 9: Create a Deployment file in the View-Controller and Deploy this to a WAR file
Step 10: Create a Deployment file in the View-Controller and create an EAR file and add Model’s JAR and View-Controller’s
WAR files to it.
Step 11: Run the JSP Files
SCENARIO END
Now, When I execute Index.jsp, it does not list values from database and when I click on Create User link, it takes me to adduser.jsp page. When I fill values in this page and click Save button, it takes me to Save Failed page and data does not persist to the database.
WHAT IS WRONG OUT HERE ???If you set a breakpoint in your createUser method - does this code get executed?
We have a couple of tutorials that might show you how to do this.
EJB/JSF with ADF-binding tutorial:
http://www.oracle.com/technology/obe/obe1013jdev/10131/ejb_and_jpa/master-detail_pagewith_ejb.htm
EJB/JSF without ADF binding:
http://www.oracle.com/technology/obe/JavaEE_tutorial_10131/index.htm -
JSF - EJB 3.0 Application - Data does not persist to the database
Hi,
I am developing a JSF - EJB application and the data that I send from JSP Page through JSF Managed Bean --> Session Bean --> Java Persistence does not persist in database.
Here is my scenario ( Iam using JDeveloper IDE to create this application) -
------------------------------------------------------- SCENARIO START
The scenario consists of two web pages, one enlisting all the users stored in the database, the other contains a form for adding a user
1.) INDEX.JSP
2.) ADDUSER.JSP
Step 1: Create the USERS Table in database
CREATE TABLE users
user_id serial,
username varchar(255) NOT NULL,
first_name varchar(255),
last_name varchar(255),
password char(64) NOT NULL,
CONSTRAINT pk_users PRIMARY KEY (user_id)
Step 2: Add Database Connection To JDeveloper
Go to Database Connection Navigator and create a New Database Connection using the Wizard
Step 3: Create a New Application in JDeveloper and select JSF, EJB from Application Template
Step 4: ENTITY BEAN - In the EJB Node Right Click and Select EJB � New Entites from Table (JPA/EJB3.0)
Use The Wizard and create Entity Bean from Users Table which creates an Entity Bea POJO file as follows �
User.java -
package lux.domain;
import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQuery;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
@Entity
@NamedQuery(name = "User.findAll", query = "select o from User o")
@Table(name = "USERS")
public class User implements Serializable {
@Column(name="FIRST_NAME")
private String firstName;
@Column(name="LAST_NAME")
private String lastName;
@Column(nullable = false)
private String password;
@Column(nullable = false)
private String username;
@Id
@GeneratedValue(strategy=GenerationType.SEQUENCE, generator="users_seq_generator")
@SequenceGenerator(name="users_seq_generator", sequenceName="users_user_id_seq")
@Column(name="USER_ID", nullable = false)
private Long userId;
public User() {
public String getFirstName() {
return firstName;
public void setFirstName(String firstName) {
this.firstName = firstName;
public String getLastName() {
return lastName;
public void setLastName(String lastName) {
this.lastName = lastName;
public String getPassword() {
return password;
public void setPassword(String password) {
this.password = password;
public String getUsername() {
return username;
public void setUsername(String username) {
this.username = username;
public Long getUserId() {
return userId;
public void setUserId(Long userId) {
this.userId = userId;
Step 5: STATELESS SESSION BEAN - In the EJB Node Right Click and Select EJB � New Entites from Table (JPA/EJB3.0)
Again Right Click on Model and create Session Bean from Wizard which creates two files �
UserDAOBean.java � Stateless Session Bean
UserDAO.java � Local Interface
package lux.facade;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;
import lux.domain.User;
@Stateless(name="UserDAO")
public class UserDAOBean implements UserDAO {
@PersistenceContext(unitName="Model")
private EntityManager em;
public UserDAOBean() {
public User getUser(int UserId) {
User u = new User();
u = em.find(User.class, UserId);
return u;
public List<User> getAllUsers() {
Query q = em.createQuery("SELECT u FROM User u");
List<User> users = q.getResultList();
return users;
public void createUser(User u) {
String hashedPw = hashPassword(u.getPassword());
u.setPassword(hashedPw);
em.persist(u);
public void updateUser(User u) {
String hashedPw = hashPassword(u.getPassword());
u.setPassword(hashedPw);
em.merge(u);
public void deleteUser(User u) {
em.remove(u);
private String hashPassword(String password) {
StringBuilder sb = new StringBuilder();
try {
MessageDigest messageDigest = MessageDigest.getInstance("SHA");
byte[] bs;
bs = messageDigest.digest(password.getBytes());
for (int i = 0; i < bs.length; i++) {
String hexVal = Integer.toHexString(0xFF & bs);
if (hexVal.length() == 1) {
sb.append("0");
sb.append(hexVal);
} catch (NoSuchAlgorithmException ex) {
Logger.getLogger(UserDAOBean.class.getName()).log(Level.SEVERE, null, ex);
return sb.toString();
Step 6: Create a Deployment file in the Model and Deploy this to a JAR file
Step 7: Now Right Click on View/Controller Node and create a Java File �
UserController.java -
package lux.controllers;
import javax.ejb.EJB;
import javax.faces.model.DataModel;
import javax.faces.model.ListDataModel;
import lux.domain.User;
import lux.facade.UserDAO;
public class UserController {
@EJB UserDAO userDao;
private User user;
private DataModel model;
public String createUser() {
this.user = new User();
return "create_new_user";
public String saveUser() {
String r = "success";
try {
userDao.createUser(user);
} catch (Exception e) {
e.printStackTrace();
r = "failed";
return r;
public DataModel getUsers() {
model = new ListDataModel(userDao.getAllUsers());
return model;
public User getUser() {
return user;
public void setUser(User user) {
this.user = user;
Step 8: Configure page flow in faces-config.xml
1. Create the JSP file adduser.jsp by right-clicking View-Controller
node and selecting New > JSP. Use the wizard to create JSF � JSP Page, fill in
File Name adduser.jsp, click Finish. -
<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>
<%@taglib prefix="f" uri="http://java.sun.com/jsf/core"%>
<%@taglib prefix="h" uri="http://java.sun.com/jsf/html"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>New user</title>
</head>
<body>
<f:view>
<h:form>
<h:messages/>
<h:panelGrid columns="2">
<h:outputText value="Username"/>
<h:inputText
id="Username"
value="#{user.user.username}"
required="true"/>
<h:outputText value="First name"/>
<h:inputText
id="FirstName"
value="#{user.user.firstName}" />
<h:outputText value="Last name"/>
<h:inputText
id="LastName"
value="#{user.user.lastName}" />
<h:outputText value="Password" />
<h:inputSecret
id="Password"
value="#{user.user.password}"
required="true" />
<h:panelGroup/>
<h:commandButton
action="#{user.saveUser}"
value="Save"/>
</h:panelGrid>
</h:form>
</f:view>
</body>
</html>
2. Repeat the previous step for another JSP file failed.jsp.
3. On failed.jsp add the string <h2>Save failed</h2>.
Next we configure the page flow.
1. Open faces-config.xml.
2. Create index.jsp -
<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>
<%@taglib prefix="f" uri="http://java.sun.com/jsf/core"%>
<%@taglib prefix="h" uri="http://java.sun.com/jsf/html"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>User Listing</title>
</head>
<body>
<f:view>
<h:form>
<h1><h:outputText value="User Listing"/></h1>
<p><h:commandLink action="#{user.createUser}" value="Create a user"/></p>
<h:dataTable value="#{user.user}"
var="dataTableItem" border="1" cellpadding="2" cellspacing="2">
<h:column>
<f:facet name="header">
<h:outputText value="Username"/>
</f:facet>
<h:outputText value="#{dataTableItem.username}" />
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="First name"/>
</f:facet>
<h:outputText value="#{dataTableItem.firstName}" />
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="Last name"/>
</f:facet>
<h:outputText value="#{dataTableItem.lastName}" />
</h:column>
</h:dataTable>
</h:form>
</f:view>
</body>
</html>
3. Drag an arrow from index.jsp to adduser.jsp and replace the arrow�s label to create_new_user.
4. Repeat the previous step for failed, by dragging and arrow from adduser.jsp to failed.jsp renaming the label to f
ailed
5. Finally repeat the step for adduser.jsp, by dragging from adduser.jsp to index.jsp renaming the label to success.
This creates the following faces-config.xml file �
<?xml version='1.0' encoding='UTF-8'?>
<faces-config>
<managed-bean>
<managed-bean-name>user</managed-bean-name>
<managed-bean-class>lux.controllers.UserController</managed-bean-class>
<managed-bean-scope>session</managed-bean-scope>
<managed-property>
<property-name>username</property-name>
<value>#{username}</value>
</managed-property>
<managed-property>
<property-name>firstName</property-name>
<value>#{firstName}</value>
</managed-property>
<managed-property>
<property-name>lastName</property-name>
<value>#{lastName}</value>
</managed-property>
<managed-property>
<property-name>password</property-name>
<value>#{password}</value>
</managed-property>
</managed-bean>
<navigation-rule>
<from-view-id>/index.jsp</from-view-id>
<navigation-case>
<from-outcome>create_new_user</from-outcome>
<to-view-id>/adduser.jsp</to-view-id>
</navigation-case>
</navigation-rule>
<navigation-rule>
<from-view-id>/adduser.jsp</from-view-id>
<navigation-case>
<from-outcome>failed</from-outcome>
<to-view-id>/failed.jsp</to-view-id>
</navigation-case>
<navigation-case>
<from-outcome>success</from-outcome>
<to-view-id>/index.jsp</to-view-id>
</navigation-case>
</navigation-rule>
</faces-config>
Step 9: Create a Deployment file in the View-Controller and Deploy this to a WAR file
Step 10: Create a Deployment file in the View-Controller and create an EAR file and add Model�s JAR and View-Controller�s
WAR files to it.
Step 11: Run the JSP Files
------------------------------------------------------- SCENARIO END
Now, When I execute Index.jsp, it does not list values from database and when I click on Create User link, it takes me to adduser.jsp page. When I fill values in this page and click Save button, it takes me to Save Failed page and data does not persist to the database.
WHAT IS WRONG OUT HERE ???PLZZZZZZZZZzzzzzzzzzzz HELP ! ! !
-
Issue with posting change note processing using movement type 309
while processing Posting change note using transaction LT05, i am getting error 'Available quantity is less than selected quantity'. we need the quantity in posting change note to be picked from same storage bin from where it has been picked during transfer posting using 309. currently, it is showing all storage bins in ascending order for selection while Posting change note posting.
if we reqwhile mass porcessing of Posting change note using LSMW, it pickes the 1st storage bin. if 1st storage bin quantity is less than selected quantity of PCN then it is showing above error.Hi Vishal,
The materials are managed by batch? Please check the batches of the material in the different storage bins. SAP asign the storage bin taking into account the material batch number and the oldest quant.
When the storage bin is not indicated, SAP looks at the batch number, and goes to the storage bin where this batch for the material is allocated. If SAP find more than one storage bin, SAP consumes from the batch that has the oldest quant.
I really dont understand deeply your question.
Hope it helps.
Regards
Enzo -
I'm having trouble with my changes not being saved/published.
I can choose to edit a page, click publish... it then shows the
page (in contribute) with my changes. But, when I go to the actual
website, the changes are not there... and when I go back to
contribute and move around in contribute's view of my website and
go back again to the page I was working on.. the changes are no
longer there.
thoughts? Should I uninstall and re-install
contribute?No, don't uninstall...
First, emty the cache of you Internet Explorer and see if you
can see the changes then.
1. Main menu in IE, go to Extra>(internet)Options
2. go to Browsing History
3. click Remove... (delete/empty, I don't know the text of
the btn in english version) and emty your cache.
Second, change the settings of IE.
1. Main menu in IE, go to Extra>(internet)Options
2. go to Browsing History
3. click Preferences (next to Remove.. btn mentioned above)
4. change the setting for Temporary Internet files so that
the pages refresh everytime you visit the pages.
Maybe you are looking for
-
hi, We have some troubles in Risk analysis and Remediation. In the configuration tab, background job: -User/Role and Profile Sync are OK -But when we launch a user, role or profile analysis we always have the statuts error and the error message(in jo
-
Can I e-mail a Photo "Album" from my iPad. If "yes," please explain how to attach it. thanks
-
PS CS5 not saving preview for EPS files
I'm running a trial version of CS5 Design Premium on a brand new Core i5 iMac with 8GB RAM and running SL 10.6.3. So far, I haven't noticed any major glitches, except for the following: When I save an image as EPS, I usually choose the standard Mac 8
-
Hi, we are in process of configuring CEN from Solution Manager and we are using Auto reaction methods for sending alerts. we have setup some transactions like SM37 and ST22 and it is triggering an alert for every failed job znd every dump. Can we set
-
Question I have just downloaded Firefox 4 and my autofill on the google toolbar is not working for any webpages it previously worked with. Is there a way to fix this? Thanks