i have a button in my form with following code :
<p:commandButton value="#{msgs['message.report.button.search.show']}"
icon="ui-icon-image" id="searchBtn"
process="#this"
actionListener="#{sixteenFormController.search()}"
update=":assetListForm">
</p:commandButton>
when i click on the button first time it dosen't call backing bean method. but in the next time it work correct. i check request header in each time. request header for first click was :
assetListForm_SUBMIT=1
javax.faces.partial.ajax=true
javax.faces.partial.execute=searchBtn
javax.faces.partial.render=assetListForm
javax.faces.source=searchBtn
searchBtn=searchBtn
and for second click :
assetListForm_SUBMIT=1
javax.faces.ViewState=5LLh2g4iknGg3jt6KJ36nXF8zkcaHWvjQA7VyP8TZwTyqsEL3FtbchUbjpDpGamapf1UcXd7boDtNqJEmCRczCh95LNnr7zECPAaf7kdL3HVm04Il8TLlPrMfwhN8qVUQ7dpUuNFJN8douQpHAmi3p2hyfX1+yA8pAbzIvcKXU8fTqLwlZkFBjcDJVCG5AbDYsa0UIeckLkq9CdxrhUjUu5di/iwcSFhZmHYXVEUD3I8LyBLYPi7CNNjF9A1MBUAP8+eOy7EfkRi4HqQQcifnG61b04jANvzSmRbwwZhlBv6POOENqd9MQ+QVXbt7glrR8sv+A4L4DeFE49VGcRYkmt6f2AsbHg9hkVUnT2yewSFahrdbZ+jHQ92s9dqKCu54hMEma8gQ1rKjdl/0OZGH+sIvrhOBgoCShS5b7yILe0SzOpL1lYLRY331kvhpn/dz1wbZp1QgI3Ti6WpELABYHHt+3hz2qI21Hd1ivtQHuAtTqssTQt8Ne/9b0NPyXcdzuGkLnDdtbdnjURUQmP2UwJSQXPjyQrAwTlGGEEEG46v1U0/O+vOz4rpyIGlhyYi+ep9AqEKlIdDdMPPGerV8XTbtnYeKvSqht3m9M3Q1bzKjdl/0OZGH+sIvrhOBgoCShS5b7yILe3h5m76UOP4/3MimmxBWV7T7e/U8IjMZFuw0OnmGT9a72t/TxydgtiFX4mH+PRhO23X7M3DgDAKEq6EmpCziqr5MCY99K5xVcbg0uMJR3llgTZb948nWXUYGEVuCJagYHoalPbjRNWFNP3RW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lQUzSTH9Qcyx7Mq6P3SI2hEbr1YKXZdNTvx/Ay93PSlBqU9t9PzV+x75uUWq8bVfvXdYoAi11v2RddzU//Wwnj01nx6YoFrUUGs/Z0Va7NJuNEsKwQ==
javax.faces.partial.ajax=true
javax.faces.partial.execute=searchBtn
javax.faces.partial.render=assetListForm
javax.faces.source=searchBtn
searchBtn=searchBtn
do you know reason of this behaviour?
thanks.
It can be related with the issue https://java.net/jira/browse/JAVASERVERFACES_SPEC_PUBLIC-790. Look how fix this issuse, for example, in the link: how to fixe twice needed click inside JSF page?
Related
I have a JSF/PrimeFaces form page set up to edit some configuration details. At the bottom are Submit and Cancel buttons implemented as CommandButton. The Cancel button looks like this:
<p:commandButton
action="priorPage.xhtml?faces-redirect=true"
value="Cancel" />
The problem is that the view bean still winds up doing more processing on the data that's been entered into the form than I'd like. It isn't updating anything in the database, but if (say) I enter a string into a field that's looking for a numeric in the bean, it still produces errors.
Part of my solution is, of course, to get the bean to gracefully handle that sort of bad data, and I'm working on it. But I'd also like to tweak that button so that it just takes the user to the prior page. Is there some attribute I can set that will prevent the form from being processed at all?
The <p:commandButton> submits the form. You don't want to submit the form. You should then not use the <p:commandButton>, but just <p:button>.
<p:button value="Cancel" outcome="priorPage.xhtml" />
See also:
Difference between h:button and h:commandButton
I have a JSF/PrimeFaces form page set up to edit some configuration details. At the bottom are Submit and Cancel buttons implemented as CommandButton. The Cancel button looks like this:
<p:commandButton
action="priorPage.xhtml?faces-redirect=true"
value="Cancel" />
The problem is that the view bean still winds up doing more processing on the data that's been entered into the form than I'd like. It isn't updating anything in the database, but if (say) I enter a string into a field that's looking for a numeric in the bean, it still produces errors.
Part of my solution is, of course, to get the bean to gracefully handle that sort of bad data, and I'm working on it. But I'd also like to tweak that button so that it just takes the user to the prior page. Is there some attribute I can set that will prevent the form from being processed at all?
The <p:commandButton> submits the form. You don't want to submit the form. You should then not use the <p:commandButton>, but just <p:button>.
<p:button value="Cancel" outcome="priorPage.xhtml" />
See also:
Difference between h:button and h:commandButton
I'm working on building a web page and notice now that I have to press the command button twice. Any command button has the same problem, so I figured I would add and action listener on one of them to see if I could see something.
<h:form id="formP">
<p:commandButton id="temp" value="photos" actionListener="#{viewBacking.debugBreakpoint()}" action="userPhoto" />
</h:form>
The backing bean has
public void debugBreakpoint() {
int i = 0;
i++;
}
Unfortunately, this does help. It hits my breakpoint only after the second press. I suspect that some field somewhere isn't passing validation but I would like some method of detecting what exactly is going wrong - why do I need the second push? Is there some option I can turn on in Glassfish, or something else where I can look at a dump of debug information? I can ignore the dump until everything is stable and then see what exactly is happening when I press the button for the first time.
Is there any such tool which I can use?
That can happen when a parent component of the given <h:form> has been rendered/updated by another command button/link with <f:ajax>. The given form will then lose its view state which it would only get back after submitting the form for the first time. Any subsequent submits will then work the usual way. This is caused by a bug in JSF JS API as descibred in JSF issue 790 which is fixed in the upcoming JSF 2.2.
You need to fix the another command button/link with <f:ajax> to explicitly include the client ID of the given <h:form> in the render.
<f:ajax render=":somePanel :formP" />
Another way is to replace this <f:ajax> by a PrimeFaces <p:commandLink> or <p:commandButton> so that you don't need to explicitly include the client ID of all the forms. PrimeFaces's own JS API has namely already incorporated this fix.
add event="onclick" in your p:commandbutton
I guess that will sort it out.
or you can add this ajax="false" property in your commandButton
<p:commandButton ajax="false" action="#{userController.create}" value="#{bundle.CreateUserSaveLink}"></p:commandButton>
I ran into the same issue. The solution was simple, instead of having both an actionListener and an action, just convert the actionListener method to return a string to where you want to navigate to and use it as the method for the action (and don't have an actionListener).
In simple terms: only use an action (do not use an actionListener on a commandButton that is submitting a form).
Please check your binding with bean.
bean fields should be String or non primitive.
I have a variable in backing bean that needs to get reset to null whenever the associated page is opened using the relevant menu link. Is there a way to run a initialization code in the backing bean whenever the relevant menu link is clicked? Contsructor runs only the first time the menu link is clicked. I guess the bean is then retained in the jsf context and is not getting recreated. Is there a way to ensure a new object of that backing bean is created each time the menu link is clicked? Thanks!
Couldn't you just put the bean in request scope?
Another option would be to use a setpropertyactionlistener on the menu. When the menu is clicked, set the value to "null".
You have the following options:
1 . Change the bean to the request-scoped bean
2 . Use the action attribute to call the method on the backing bean to run the initialization code whenever the link is clicked , something like this:
<h:commandLink action="#{myBean.init}" value="My Link" />
And myBean.init() contains the initialization code
I have a JSF page that includes a tree form tag which is rendered depending on some bean property. There are two buttons for next and previous page. I want to skip form validation on the button which goes to the previous page.
I tried the following ways to disable the validation:
Set h:commandButton immediate="true"
Change button by a4j:commandButton ajaxSingle="true" rerender="someparts"
It does not work. Why does the navigation fail when I want to skip validation?
immediate="true" does skip the validation. Make sure you have redeployed successfully, and the there aren't any errors.
I solve problem using a4j:commandButton ajaxSingle="true" reRender=":outhercomponent:formconteningcomponent:component"
reRender needs absolute path to component even if component id unique