I'm using Icefaces 1.8.2 and an ice:inputTextarea control, and I can't figure why the value is not getting set here:
.jsp
<ice:inputTextarea binding="#{easp$RecordSearch.repairRemark}" id="repairRemark"
partialSubmit="true" style="height:40px; width:100%;" />
.java
//bean
private HtmlInputTextarea repairRemark = new HtmlInputTextarea();
public HtmlInputTextarea getRepairRemark() {
return repairRemark;
}
public void setRepairRemark(HtmlInputTextarea hit) {
this.repairRemark = hit;
}
....
public String button3_action() {
...
//code that sets value
String myVal = "new value";
this.repairRemark.setValue(myVal);
...
return null;
}
The code that sets the value is part of a button click event that I know is getting fired because I'm setting several other Icefaces controls, and all the other setters are working except this one. I just noticed that it actually appears to set the text very briefly, but disappears instantly. I checked all the code on that page, and I'm almost certain there is no other setter overwriting it. Does anyone know what is going here?
Update:
It does not seem to be a "phase" related issue, as this event is being processed in the INVOKE_APPLICATION phase. Also to note, I'm experiencing the same issue with the jsf h:inputTextarea
I found the cause and solution. The cause was the ice:commandButtons that were triggering this click event were in a column in a ice:dataTable. The ice:dataTable had an ice:rowSelector that seemed like it was causing an additional server request when a button was clicked. When I removed the ice:rowSelector, the problem went away.
The solution was to add either toggleOnClick="false" or toggleOnInput="false" to the ice:rowSelector. I added both, just in case.
http://res.icesoft.org/docs/v1_8_2/tld/ice/rowSelector.html
Hope this helps anyone else that runs into this issue.
Related
i want to update the text field value when i was changed.for this i use action listener because every updation time one trigger was fired in my code so,that's the reason i used action listener instead of data changed listener.for data changed listener on key pressed the listener is called updation done but my requirement is after completion of entering the data on text field only the listener is called.but it is not calling properly.
please find the below code,
agencyWorker.addActionListener(createAgencyActionListener(agencyWorker,eventPostchedules.getSerialId()));
private ActionListener createAgencyActionListener(final TextField searchField, String serialId){
return new ActionListener() {
#Override
public void actionPerformed(ActionEvent evt) {
String agencyText = searchField.getText();
searchField.setPreferredW(110);
roasterDao = RoasterDao.getInstance();
roasterDao.updateEventPostScheduleAgency(agencyText, serialId, "supervisor");
}
};
}
thanks in advance.
I just tested this on my iPad and action listener was invoked as expected. Check that you don't have a different error that is causing this e.g. networking error related to https change in iOS.
FYI on a side note, it's really bad to write this:
searchField.setPreferredW(110);
You are limiting the size of the field based in pixels which is rarely the right thing to do. The method is deprecated for a reason...
I am making a page in which I call a PrettyFaces page-load action method:
<url-mapping id="informes-perfil">
<pattern value="/informes/#{informesPerfilMB.codigo}" />
<view-id value="/faces/informes_perfil.xhtml" />
<action onPostback="false">#{informesPerfilMB.load()}</action>
</url-mapping>
For some reason, the informesPerfilMB.load() action is called twice, and the parameter value in the second call is 'null' or 'RES_NOT_FOUND'.
Here is my load method:
public void load() {
if (isPostBack) {
isPostBack = false;
try {
System.out.println(codigo);
informe = informeEJBServiceLocal.getByCodigo(codigo);
this.buscarInformeIngreso();
this.buscarInformeOtroIngreso();
} catch (EJBServiceException e) {
e.printStackTrace();
}
}
}
The isPostBack variable is initialized to false, so this should prevent the method from being called again, but for some reason it is.
This code first prints String: dcc509a6f75849b.
Then when the load is repeated, it prints this: RES_NOT_FOUND
I hope this code helps explain what is happening enough to solve my problem, Thanks.
I've seen this happen on my similar system in the past. I think it's an interaction between faces and prettyfaces with missing files. The RES_NOT_FOUND part comes from the network traffic. There's some likely faces resource (or stylesheet) that it's trying to find in libraries and when it can't, it essentially causes the browser to go to the URL /informes/RES_NOT_FOUND. For some reason, it would often find that resource if I refreshed the page and wouldn't issue a RES_NOT_FOUND URL.
First, I'd open up the page source, and you'll find RES_NOT_FOUND, likely along with the stylesheets. Given the position of it, you might be able to correlate it to the resources loaded in your xhtml files and see which one's missing. If that doesn't help, try the developer tools and see which resources are loaded and which are not. Then make sure the resource is present, deployed, and is in the correct location.
If it's not something that you can control (like a library resource), you can always make sure your setCodigo function ignores values of "RES_NOT_FOUND".
public void setCodigo(String value) {
if (!"RES_NOT_FOUND".equals(value)) {
this.codigo = value;
}
}
You may be able to modify your security or servlet-mapping settings (in WEB.XML) to prevent URLs ending in RES_NOT_FOUND from getting to the prettyfaces pages, but I don't know enough about it to do that.
First, the reason your isPostBack variable is called twice is most likely because you have two instances of the bean, not one singleton instance. There are a few reasons this could be happening:
Your bean is request scoped and multiple requests are being made to the page.
Your bean is being created multiple times by parts of your application that use it and call the load() method.
I also believe it is possible your method is being called twice because of the way you have written your EL expression (I'm not 100% sure):
<action onPostback="false">#{informesPerfilMB.load()}</action>
^^
Note the parenthesis at the end of your method expression. I believe this will force EL to evaluate the method when the expression is evaluated. Your method expression should look like this:
<action onPostback="false">#{informesPerfilMB.load}</action>
You should also check for other places in your application where this method might be called.
Please let me know if this helps.
I tried to set up a simple JSF 2.2 application using MyFaces 2.2.8.
Since MyFaces has some context parameters that I never used before, I tried to get familiar with those.
So I got to use org.apache.myfaces.JSF_JS_MODE for the first time and ran into problems with h:commandLink.
The commandLink is trying to call myfaces.oam.submitForm() which is not defined if I set the mode to minimal-modern.
If I set the mode to minimal or normal it works.
From reading some internet articles I assume this is a bug because submitForm is neither part of jsf-legacy.js nor jsf-i18n.js nor jsf-experimental.js and it apparently is needed by h:commandLink.
Also the source code comment of org.apache.myfaces.shared.renderkit.html.util.ResourceUtils.markScriptAsRendered(FacesContext, String, String) tells me
oamSubmit script is included inside jsf.js
here:
public static void markScriptAsRendered(FacesContext facesContext, String libraryName, String resourceName)
{
getRenderedScriptResources(facesContext).put(
libraryName != null ? libraryName+'/'+resourceName : resourceName, Boolean.TRUE);
if (JAVAX_FACES_LIBRARY_NAME.equals(libraryName) &&
JSF_JS_RESOURCE_NAME.equals(resourceName))
{
// If we are calling this method, it is expected myfaces core is being used as runtime and note
// oamSubmit script is included inside jsf.js, so mark this one too.
getRenderedScriptResources(facesContext).put(
MYFACES_LIBRARY_NAME+'/'+MYFACES_JS_RESOURCE_NAME, Boolean.TRUE);
}
}
What am I missing here? Thanks in advance!
I can confirm it is a bug. Solved in MYFACES-4034 for 2.2.10
I use richfaces 3.3.3.Final with Seam and facelet.
I have plugged a profiler on my application and I have a weird behavior.
When I log all exceptions thrown by the application, I have more than 10 000 NoSuchFieldElementException in 10 minutes.
After many search, I found the problem:
When I started an ajax request by a4j:support, the NoSuchFieldElementException is thrown by the AjaxChildrenRenderer in these lines (199-202):
String componentType = (String) component.getClass().getField("COMPONENT_TYPE").get(null);
result = _specialComponentTypes.contains(componentType);
The component variable is a UIInstructions and it has no "COMPONENT_TYPE" field. So, the exception is normal.
This exception is thrown for each html block contained in my page. For example:
<h2>Test</h2>
<span></span>
When I reRender a block with html tag, the exception is thrown.
I have very complex page, so I get many of this exceptions.
How I can do to avoid this exception ? May be a parser option to avoid to go in this class for html block.
Thanks for your help.
As a temporary solution, you could modify the source code to add an instanceof check which should skip that block and then ship the modified source code with your webapp. Ship it either as a single class with identical package/class name in web project itself (javadoc-document it properly), which would always have preference in classloading over the one in the JAR, or as a modified and rebuild JAR file.
if (!(component instanceof UIInstructions)) {
String componentType = (String) component.getClass().getField("COMPONENT_TYPE").get(null);
result = _specialComponentTypes.contains(componentType);
}
As a lasting solution, you should report it as a performance issue to the RichFaces guys so that they get it fixed and release a new update, but I don't think that they will prioritize 3.3.x updates that much. I.e. it might take longer than you'd expect.
I'm facing a serious problem with ice:inputFile component.
When an error occurred while uploading process (like : invalid file name error, empty file name error, exceeding max size error), i use ice:message tag to show these error messages.
I use ice:panelPopup and display the ice:inputFile component inside it.
The problem is : when i toggle the uploading popup the error message still appears, i need any way to clear these messagses.
Please help me, any help is appreciated......................... :)
I'm not 100% sure, if I understood your question correctly, however I guess that the immediate keyword, applied on the action, which triggers the popup, will help you.
<ice:commandLink
action="#{this.popup}"
immediate="true">
<h:outputText value="foo" />
</ice:commandLink>
In regular JSF Life Cycle, action events are normally fired after the Process Validations phase. Additionally, values will be updated from the UI to the model.
The immediate property, which is available to basically every JSF component which can cause any kind of event, bypasses validation and, depending on the event type, also the Model Update phase.
alt text http://img43.imageshack.us/img43/3900/jsfimmediatecomponents.png
(Geary, Horstmann, 2008. Core JavaServer Faces - Second Edition. Prentice Hall)
You'll find more information on this topic in Suns JSF Tutorial: The immediate Attribute
Here are two things that have worked for me.
Bind your ice:inputFile component to a property on your backing bean and manually call the reset method on the property when you close the popup pane.
<ice:inputFile binding="#{Bean.uploadedFile}"/>
class BackingBean {
private UICommand uploadedFile;
public UICommand getUploadedFile() { return uploadedFile; }
public void setUploadedFile(UICommand uploadedFile) { this.uploadedFile = uploadedFile; }
public void onClose(ActionEvent event) {
((InputFile) uploadedFile).reset();
}
}
-OR-
Add an actionListener to your ice:inputFile component. This will stop the inputFile component from adding its own validation errors to the context. You can implement whatever validation you need in the actionListener method and display the validation errors using an ice:messages tag. I've found that this works better than relying on inputFile's validation because it gives you complete control over the error message text/style and because the error messages clear automatically when the popup pane goes away.
<ice:inputFile actionListener="#{Bean.onFileUpload}"/>
public class BackingBean {
public void onFileUpload(ActionEvent event) {
FileInfo info = ((InputFile) event.getSource()).getFileInfo();
switch (info.getStatus()) {
case FileInfo.SAVED :
// handle uploaded file
case FileInfo.SIZE_LIMIT_EXCEEDED :
// file too big error
...
}
}
}