#all in JSF Ajax does not work - java

This line is inside a form tag:
<p:commandLink actionListener="#{questionBean.removeQuestion(question)}"
value="Delete" styleClass="delete" update="#all"/>
However, it only works with #form. Nothing happens when I have #all. I want to be able to update not only the form but also other parts of the page.

Seems that update="#all" not supported by primefaces
although its a bit diff question update="#all" is not working with "ui:include ..."
but still its being said several time that
update="#all" does not work with PimeFaces.
another ref : Issue 2026: update="#all" is not working PrimeFaces ajax.

Try with process="#all" as explained here.
<p:commandLink actionListener="#{questionBean.removeQuestion(question)}"
value="Delete" styleClass="delete" process="#all"/>

I think it may be a bug. Even if you use JSF's <f:ajax render="#all">, it may also does not work. To solve this, I think you can simply set the id attribute of the body tag to, for example, mySexyBody. Then you can do update="mySexyBody".

Related

ColorPicker on jsf page

I need color picker on my page.
First, I placed Primefaces' colorpicker, but when I tried to use it, I received "IllegalArgumentException: text/xml is not a supported mime type". Probably this occurs because I use my own jquery library, which has no colorpicker element, and it overrides Primefaces' one.
So, I tried it in other way. I used "jscolor" library which turns any input field to colorpicker. I got component:
<h:inputText value="#{searchManagedBean.selectedColor}" class="color"/>
It works perfectly, but when I submit form, value in backing bean doesn't update. In backing bean I have getter and setter for this field, so I can't figure out what is the reason of this problem.
Could you help me with one of these problems, or maybe provide another solution?
Thanks!
I found the solution. If I update the value in some other element, value in backing bean updates too. So, now I have something like this:
<h:inputText value="#{searchManagedBean.selectedColor}" class="color">
<p:ajax event="change" update="outcolor"/>
</h:inputText>
<h:outputText style="display: none" id="outcolor" value="#searchManagedBean.selectedColor}"/>
For me, it's very strange behaviour. I don't know why it works, but it works!

how to change css of the image link when clicked?

i have a commandLink that has a graphicImage inside and i want to change some property
of the link to show that it is clicked.I could find no built-in property for that purpose.
Maybe some javascript or css code is required.Since i am not so good at those,i'd be glad if someone could guide me a way.Thanks
Here is the code of the link.
<p:commandLink title="Forward" update="growl"
actionListener="#{roombaBean.forward}">
<p:graphicImage value="images/but_forward.png" />
</p:commandLink>
Use onclick event of the commandLink to execute javascript.
Something like
<p:commandLink onclick="changeCSSInJavascript()" ...>
....
</p:commandLink>
You could add a style attribute to primefaces graphicImage and give it a string value from a bean. After the link it's clicked you could update that string value with: opacity:0.4:
<p:commandLink title="Forward" update="growl"
actionListener="#{roombaBean.forward}">
<p:graphicImage value="images/but_forward.png" style="#{myBean.myStringStyleValue}" />
</p:commandLink>
For IE8 and earlier use filter:alpha(opacity=40);
Anyway I don't really understand why do you want something like this? Don't you navigate away from the page? Why is it really matter that the image was clicked? Please, if you could give some more info, we could see if there is a better solution...

No component found to process as 'ajaxSingle'

Found strange problem, possibly bug.
I have 2 identical web-pages with Richfaces:suggestionbox.
On the first one my suggestionBox is doing well, everything works fine, but on another one i have some problems. SuggestionBox doesn't show my suggestions. In logs i have something like this:
WARNING: No component found to process as 'ajaxSingle' for clientId remains-form:konta-suggest
2010.1.9 12:02:29 org.ajax4jsf.component.AjaxViewRoot processPhase
Any conclusions?
UPD:
<h:inputText value="#{repobean.kont}" id="kont" label="Payer" style="width:230px;"/>
<rich:suggestionbox onobjectchange="printObjectsSelected(#{rich:element('konta-id')}, #{rich:component('konta-suggest')}, 'id');" usingSuggestObjects="true" width="230" var="result" fetchValue="#{result.kont}" suggestionAction="#{kontabean.suggest}" id="konta-suggest" for="kont">
<h:column>
<h:outputText value="#{result.kont}"/>
</h:column>
<h:column>
<h:outputText value="#{result.kontName}"/>
</h:column>
</rich:suggestionbox>
<h:inputHidden id="konta-id" value="#{repobean.kontId}" />
Javascript inside onobjectchange is a function which prints id into konta-id.
The code of jsp on the second page is copy-pasted from the first page.
I know, the question is 5 years old, but we had this same error (with different components)
In our case we have changed the outer ui:repeat to an a4j:repeat.
After that, our components worked as expected.
What you can do, when you encounter Ajax problems, is to add the <a4j:log> component:
<a4j:log popup="false"/>
This will create a box in your page with all the Ajax logs from Richfaces. Eventually, you can set popup="true" and then display the popup by Ctrl + Shift + L
There are many logs in this panel, but generally the important things to look at is the WARN or ERROR messages.
Other concern about your error message: it is talking about some ajaxSingle processing. In your JSF code, you have no ajaxSingle attribute defined. When does this error happens? When you start typing some characters in your inputText component?
Isn't there any conditional rendering (rendered="#{some expression}") around this input and suggestion components? Or an iteration?
Does .suggest() action get invoked before this error?
Situations like you've described happen when an action-related (causing) component is within a conditional render (or an iteration) which does not allow a component to be created on RestoreView phase. Then action is not called at all and component-id is not found in the component tree.
Example: if you have something like this:
<h:panelGroup rendered="#{not empty myBean.valueSetInActionHandler}">
<h:commandLink id="action1" action="#{myBean.callOtherAction" value="appears after action"/>
</h:panelGroup>
<h:commandLink id="action2" action="#{myBean.setValueInActionHandler}" value="display button above"/>
First render - only one, second button is rendered. If setValueInActionHandler sets some value and displays the same page - first button ("appears after action") will get rendered too. But clicking it won't fire a callOtherAction - because on second request, during RestorePhase valueInActionHandler is empty again, so action1 will not be available...
Hope I managed to make myself clear :)
I think a4j taglib is missing on the page.

JSF - 2 a4j:actionParam in one commandlink bug

I have such structure in my jsp:
<h:commandLink action=#{docbean.save}>
<a4j:actionParam name="somename" value="bill_all" assignTo="#{billdoc.billType}"/>
<a4j:actionParam name="somename" value="bill_document" assignTo="#{docbean.doctype}"/>
</h:commandLink>
While debugging i saw, that billdoc.billtype and docbean.doctype have the same values: "bill_document".
Is it bug? If not, then how can i put value to my managed-bean?
UPDATED:
Found the answer:
I had two actionParams with one name. ActionParam is f:actionListener + f:param. So, if you have several actionparams with one name, you will have the problem i had. RichFaces and JSF doesn't warn you about it.
First, you need a space here <a4j:actionParamvalue - before value
Second, You may try this instead of <a4j:actionParam>:
<f:setPropertyActionListener value="bill_all" target="#{billdoc.billType}" />
You may need to put immediate="true" on your commandLink if there are validation errors in your form. You can view these errors by adding <rich:messages /> ontop of the page.
Try using an a4j:commandLink. Or - if you stick to h:commandLink - try embedding your a4j:actionParams in an a4j:support tag.

How to use RichFaces a4j:commandButton not using submit

I have an a4j:commandButton which looks like this
<a4j:commandButton id="stopBtn" type="button" reRender="lastOp"
action="#{MyBacking.stop}" value="Stop" />
</a4j:commandButton>
When the app is deployed, and the button clicked, the stop() method is not being called. All the a4j:commandButton examples refer to forms, but this button is not in a form - it's a button the user is going to use to cause the server to run some back-end logic. At the moment, the method is
public void stopNode() {
logger.info("STOPPING");
setLastOp("Stopped.");
}
Other methods which don't use this type of button are updating the lastOp field, but I'm not seeing anything on the console with this one. Am I right to cast this as a button? Should I put this in a h:form tag?
The firebug console says:
this._form is null
which I don't understand.
Any help well appreciated.
UICommand components ought to be placed inside an UIForm component. So, your guess
Should I put this in a h:form tag?
is entirely correct :) This because they fire a POST request and the only (normal) way for that is using a HTML <form> element whose method attribute is set to "post". Firebug also says that a parent form element is been expected, but it resolved to null and thus no actions can be taken place.
Only "plain vanilla" links like h:outputLink and consorts doesn't need a form, because they just fires a GET request.
Yes, wrap it in a form. I'm sure BalusC will post a detailed explanation while I'm typing my answer. (yup, there it is)
I have to ask why you didn't just try a form first, before posting here.
Look at your code:
<a4j:commandButton id="stopBtn" type="button" reRender="lastOp" action="#{MyBacking.stop}" value="Stop" />
You finished <a4j:commandButton with />, why need that orphan </a4j:commandButton> ?
If for some reason you don't want to place the button inside a form, you can do something like this:
<a4j:commandButton onclick="fireAjax()"/>
<h:form>
<a4j:jsFunction name="fireAjax" action=".."/>
</h:form>

Categories

Resources