JSF setting bean fields without overring values.
Imagine I have two <h:inputText> components:
One is a SSN (Social Security Number) inputText and the other one is a Name component.
I have put a onValueChangeListener on my SSN inputText for when its value changes.
When it changes, I call a Business Method which accesses a DAO and retrieves the person's Name from a DAtabase.
on the onValueChangeListener method I set: beanName.setName(XXDAO.findXXXBySSN(ssn)).getName())
something like that...
the problem lies in the Update Values Phase because all the values I set in the Listener method are overriden by the Update Values PHase. They get set with the old form values and all the processing I do is worth nothing...
Any help???
Yeh its a problem because the value changed is called before the model update.
So what you can do
you can update the variables yourself then call
FacesContext.getCurrentInstance().renderResponse();
in your value change this will skip the model update
(note i have found a problem with the view not refreshing with this still unresolved problem i have a post ongoing about this)
with renderResponse you can also make a navigation rule to navigate back to the same page and call it in your value changed method.
FacesContext.getCurrentInstance().getApplication().getNavigationHandler().handleNavigation(FacesContext.getCurrentInstance(),null,"test");
where test is the navigation rule
this will force the view to be updated
The other soultion i found to this was to move the value changed event to the model update phase. This way your setters are called before yoru value changed event
something like
public void changeMethod(ValueChangeEvent event)
PhaseId phaseId = event.getPhaseId();
String oldValue = (String) event.getOldValue();
String newValue = (String) event.getNewValue();
if (phaseId.equals(PhaseId.ANY_PHASE))
event.setPhaseId(PhaseId.UPDATE_MODEL_VALUES);
event.queue();
// correct phase update local variables for the new class Number
else if (phaseId.equals(PhaseId.UPDATE_MODEL_VALUES))
}
Similar Messages
-
Setting Acroform field properties (not values) by importing FDF?
Am I crazy or is there a way to set "hard-to-set-field-properties-unless-you-use-javascript" by importing an FDF document. Currently, when we are programatically adding fields to an AcroForm (some of our customers still require AcroForms) we can't set certain field properties because the API doesn't expose those properties for some reason. I think I remember reading that you can import an FDF file to set field properties (not field values). Is this true?
ThanksThis is a list of some of the properties that a fellow developer gave me that had to be set by executing javascript within Acrobat:
fillColor
borderStyle
strokeColor
lineWidth
doNotScroll
We aren't setting these properties during the end-user experience. We just need to do it programmatically during the design phase.
I was wondering if we could import an FDF to set these properties. Heck, even better it would be great if we could import an FDF to create and position fields and set all of there properties. Is any of this possible? -
How can you set a value in a bean from the view?
See
http://java.sun.com/webservices/docs/1.3/tutorial/doc/JSPIntro8.html#wp70763
for a bean with a property that has get and set methods.
The SQL tag examples are helpful examples
http://java.sun.com/webservices/docs/1.3/tutorial/doc/JSTL7.html#wp63722 -
Dynamically set report field value
In my old classic VB project, I was able to set a report field value using the following simple line of code.
someReport.SomeField.SetText u201Cabcu201D
This was nice and simple, now with crystal reports .Net I do the following:
((TextObject)someReport.SectionX.ReportObjects["SomeField"]).Text = u201Cabcu201D;
Itu2019s simple enough but seems too elaborated compared to the good old VB6.
Not that is a big deal but is there a simpler way (Classic VB6 style) to set a field on a report without me having to create my own utility method to u201Csimplifyu201D things?
Thanks.Perhaps using a formula?
Imports CrystalDecisions.CrystalReports.Engine
Imports CrystalDecisions.Shared
Public Class Form1
Inherits System.Windows.Forms.Form
Dim Report As New CrystalReport1()
Dim FormulaFields As FormulaFieldDefinitions
Dim FormulaField As FormulaFieldDefinition
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
FormulaFields = Report.DataDefinition.FormulaFields
FormulaField = FormulaFields.Item(0)
FormulaField.Text = "[formula text]"
CrystalReportViewer1.ReportSource = Report
End Sub
Other than that, InProc RAS, but if the solution you have is complicated, you ain't seen nothing yet
- Ludek -
To allow me put a value into field without coming out the tcode.
Hi Friends,
My requirement is when a value is entered into a field leaving the other field empty should display a error message
I'm making use of the below statement to display the error message
message S000(01) display like 'E' raising error_with_message.
But the thing is ,when trying to save it after entering value into a field leaving the other empty, its displaying the error message which i have maintianed.till here its well and good.But from here I can only come out of the tcode without allowing me to enter the value into the other field.
want a message to be displayed on the status bar and allow me to put the value into the remaining field
without coming out from the screen..
Please help..Hi laxman,
Are you saying like this..
message S000(01) dispaly like 's' raising error_with_message.
set screen 100.
leave screen.
The Req is "If I enter a value in field leaving the other field empty in tcode XXXX..its should display a message that this particular field is mandatory and allow me to put the value into the other field "
I'm able to display a message when the second field is left empty..
In the message dialog (where the message gets displayed), exit option is there.so i'm coming out of the tcode.But it should give me message and allow me to put the value in the screen without coming out of it. -
How to set bean property in jsf page
Hi,
Hopefully theres an easy solution, but I can't figure it out...
I have a managed bean that spans several jsf pages.
Within each page I want to set a flag that tells the bean which page it is serving (as well as some other params).
How do I set a property of the bean in the page?
I've tried
<jsp:useBean id="filter3" scope="request" class="com.aol.rsistats.ui.FilterBean"/>
<jsp:setProperty name="filter3" property="filterType" value="3"/>
but that doesn't load the page through the normal JSF routine (and I initialise some values of the bean in the faces-config.xml file... so these are not initialiased when the setProperty is called) .
(In general I get some strange behaviour when I mix jsf tags with jsp, or jstl, so I've avoided it as much as possilble)
Is there another way?
Cheers,
KeithThis example works for me (using jsf-1_1_01).
Index.jsf:
<%@ page contentType="text/html; charset=UTF-8" %>
<%@ page language="java" %>
<%-- jakarta-taglibs-standard-1.0 --%>
<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %>
<%--
Note, that with jakarta-taglibs-standard-1.1.1 taglib directive
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
the example NOT works!!!
--%>
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
<html>
<head>
<title>MyTitle</title>
</head>
<body>
<f:view>
<%--
Do not delete the following lines! You need to address to WIManager before using c:set.
--%>
<!--
<h:outputText value="#{WIManager != null}"/>
-->
<c:set target="${requestScope.WIManager}" property="bpId" value="bpIdValue"/>
<h:form id="MyWebFormTask" >
<h:commandButton id="ok" action="ok" value="Ok"/>
<h:inputHidden id="bpId" value="#{WIManager.bpId}"/>
</h:form>
</f:view>
</body>
</html>
ok.jsf:
<%@ page contentType="text/html; charset=UTF-8" %>
<%@ page language="java" %>
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
<html>
<head>
<title>MyTitle</title>
</head>
<body>
<f:view>
WIManager.bpId: {<h:outputText value="#{WIManager.bpId}"/>}<br>
</f:view>
</body>
</html>
In ok.jsf I can see WIManager.bpId property set in Index.jsf.
faces-config.xml:
<managed-bean>
<managed-bean-name>WIManager</managed-bean-name>
<managed-bean-class>my.package.WIManagerBean</managed-bean-class>
<managed-bean-scope>request</managed-bean-scope>
<managed-property>
<property-name>bpId</property-name>
<property-class>java.lang.String</property-class>
<value>#{param.wim_bpid}</value>
</managed-property>
</managed-bean>
Resume:
-- use <%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %>
instead of <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
-- address to WIManager before using c:set. -
HCM F&P - How to set the field as Required based on drop down values
Hi Experts,
I have a requirement to set the Date field as mandatory when a particular value is selected in drop down list. I have already tried with MessageBox though it displays the error message but process moves further i.e. on clicking Check & Send button it throws an error message but still it moves further and i can see only Send button. Ideally it should halt there itself.
Thanks & Regards,
Jitesh TalrejaThanks for your valuable inputs
Chintan
I have already tried this. It only highlight the field with the red border but still allow to move further.
Mukesh
Yes, we can definately control this from the backend but that would be the last option i should execute. Ideally, this is something to be controlled in front end itself
Poornima
By setting the field attrbiute Required will set the field mandatory as a whole irrespective of drop down values or any other UI element.
Regards,
Jitesh Talreja -
Set the field value, call transcation T-CODE in CRM
Hello
I face the proble as follow: select the field into the itab,and set the field itab-field to call transcation T-CODE in CRM.
exp:call T-CODE:"CRMD_BUS2000111". when I execute the program, display the opportunity value screen, not the init select&result screen.
Thanks!Please reward and close your other post regarding a similar problem.
If you don't want the initial screen, you have fill the BDC data for the initial screen and then call the transaction with mode 'E'. I gave the same solution to your previous question. -
my IPhone is asking me to type in my password for my old Apple ID that does not exist anymore. I cant set up ICloud without typing in a password to a Apple ID that does not exist, so do I have to remove everything from my IPhone and start over?
Hello miamat2017
You should see an option to skip that step and then sign out of it when looking in Settings. Check out the article below for more information.
iOS 7: If you're asked for the password to your previous Apple ID when signing out of iCloud
http://support.apple.com/kb/ts5223
Regards,
-Norm G. -
Entering numeric values in CHAR field without quotes
We are upgrading from Oracle 9i to 10g. In 9i we were able to add numeric data into a CHAR field without single quotes like
insert into table (id, name, ...) values (1, 'some name', ....)
When we migrated to 10g, we are getting database errors.
Any ideas on what can be causing this and why it worked on 9i and not on 10g?
ThanksGot an example, it seems to be working fine for me.
ME_XE?create table tttttest( char_col char (5));
Table created.
Elapsed: 00:00:00.46
ME_XE?insert into tttttest values (111);
1 row created.
Elapsed: 00:00:00.65
ME_XE?select * from tttttest;
CHAR_COL
111
1 row selected.
Elapsed: 00:00:00.39
ME_XE?
ME_XE?@version
BANNER
Oracle Database 10g Express Edition Release 10.2.0.1.0 - Product
PL/SQL Release 10.2.0.1.0 - Production
CORE 10.2.0.1.0 Production
TNS for Linux: Version 10.2.0.1.0 - Production
NLSRTL Version 10.2.0.1.0 - Production
5 rows selected.
Elapsed: 00:00:00.57
[pre[ -
When I try to access iTunes or safari, I get the following message:The procedure entry point QTCF_CFHTTP message set header field value could not be located in the dynamic link library QTCF.dll I uninstalled and reinstalled.same result HELP!
Taken at face value, you're having trouble with a QuickTime program file there.
Let's try something relatively simple first. Restart the PC. Now head into your Uninstall a program control panel, select "QuickTime" and then click "Repair".
Does the repair go through okay? If so, are you able to launch iTunes and/or Safari now? -
Set External Field Value by Workflow
Is there any way to Set External Field Value by SPD 2013 workflow?
Hi j.kiani,
According to your description, my understanding is that you want to update an external column in a list by SharePoint workflow.
I did a test:
Create a list with an external column
Create a workflow , and add ‘Set Field in Current Item’ action, select the field is the external column, set the value to a value from the External Content type data source
Publish the workflow and start it on an item
The external column was changed to the value that I set in workflow. However, when I refreshed the external column by clicking the ‘sync’ flag, the data was changed to the old value.
I used ‘Update ListItem’ action, the result was same
It seems that there is not an OOB way to change external column with SharePoint workflow. You can change the external column by SharePoint web OOB way (Editing item) .
I hope this helps.
Thanks,
Wendy
Wendy Li
TechNet Community Support -
How do I set (or auto populate) the value of a modal dialog field using javascript?
I have a Modal Dialog on my SharePoint 2010 page the following fields: Your Name, Subject, Priority, Message.
It links to a list I have on the site. The second field, Subject, I want to auto populate it when the window opens, so the user can leave it as is or modify the subject. I want to set the field value using javascript.
I've tried setting the field with this code:
document.getElementById('Subject').value = "Test";
and also, this:
setFieldValue('Subject','My custom value');
Neither work.
How do I set the value of the subject field when the user first opens the dialog using javascript?
Please help.I am sure, you are looking at default field value of a list column(single line) in a modal window, if so please try below code
<script src="https://code.jquery.com/jquery-2.1.0.min.js" type="text/javascript" abp="397"></script><script type="text/javascript" abp="398">
$(document).ready(function(){
$('input[name*="Subject"]').val("Test");
</script>
Please 'propose as answer' if it helped you, also 'vote helpful' if you like this reply. -
How to close popup with af:commandButton without submitting values?
Hi all,
I'm using JDeveloper 11.1.2.1
My popup has few af:inputText components with value attribute binded to view scope variables.
I set those view scope variables in backing bean before showing popup.
When I change values of input fields and click cancel (af:commandButton, partialSubmit=true, immediate=true), popup is closed.
Then, when I show popup again, values that I changed are visible although I set new values to view scope variables in backing bean before showing popup again.
I noticed that when I close popup using close icon in upper right corner of popup everything works fine.
Also, I tried using dialog cancel button and it also works fine.
Is there a way for closing popup using af:commandButton but without submitting values?
In previous releases of JDeveloper (<= 11.1.1.5) I didn't noticed this problem.
Thanks in advance,
AleksandarAlexandar wrote:
Is there a way for closing popup using af:commandButton but without submitting values?If you really want to use your own button without submitting, then some three lines of Javascript will do the trick. See the documentation of af:popup for that. Canceling a popup is a pure client-side operation. No event is sent to the server. No submit. No need to reset anything. That's basically what the built-in cancel button does as well.
Sascha -
How to populate a set of fields multiple time in the page ?
Hi All,
JDev Ver : 11.1.1.5
I have a requirement as follows,
My page contains 1. Add Button
2. Five fields.(one input text and four select one choice)
The fields are like one input text and remaining select one choice. And also these fields contains validations.
Actions
On click of add button , I have to show the fields , similarly I have to add one more set of fields in the page below the first set when I click the add button, Like this I will add as many as I need.
How to achieve this requirement,
1. Do I need to generate the view objects dynamically from managed bean ?
2. Do I need to create a custom component ?
For Time being , I have added 3 set of fields pages and showing one by one. I want to do this dynamically.
Please let me know the suggestion for this Requirement.
Thanks,
GopinathHi,
to do this:
1. reate a managed bean that exposes a HashMap property. The HashMap is of type e.g. Map<Person>
2. To create a new set of fields, add a new entry to the HashMap and refresh the af:form. The af:form contains and af:forEach that you use
to iterate as often as you have entries in the HashMap. Each text field you bind to #{bean.HashMapProperty['key'].attribute}, for example
#{bean.HashMapProperty['key'].FirstName}
#{bean.HashMapProperty['key'].LastName}
#{bean.HashMapProperty['key'].EmployeeId}
3. When the user updates a field, the HashMap is updated based on the "key"
4. The managed bean should be in viewScope and referenced from the field's value property
Frank
Maybe you are looking for
-
Depicting multiple rows' data in one row
Hi All, Pls. check the below query: select manager_id mg_id, employee_id emp_id, last_name name from employees where manager_id = '100' and DEPARTMENT_ID = '80'if i run the following query, then o/p comes row wise; like below: mg_id
-
BADI /SAPAPO/AM_ALERTLIST - How to fill values in new field catalogue
Hi, I need some help for passing values into the field Catalog of an ALERT Monitor. The requirement is to add new fields in the ALERT Monitor and then populate them with values form the PRODUCT view. I have implemented method MODIFY_ALERTLIST of BADI
-
ITunes does not open when iPod Touch is connected
Prior to iTunes 9, I could connect my first-gen iPod Touch and iTunes would open automatically. It does not do that anymore. Is there anyway to fix this? Thanks, vidg
-
I live in Malaysia, i want to pay an application with a french visa card. Not possible?
-
Hi Guys, I want to replicate the product category from ECC to the SRM system, can you please tell me the steps to do this? Also is it possible to have both the long and short description from material group in ECC to SRM system? Thanks in advance. Re