wood burning stoves 2.0*
The moose likes JSF and the fly likes Troubles with rich:modalPanel Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSF
Bookmark "Troubles with rich:modalPanel" Watch "Troubles with rich:modalPanel" New topic
Author

Troubles with rich:modalPanel

Juliano Sott
Greenhorn

Joined: Jul 13, 2009
Posts: 3
Sorry for my bad English.

I need to save a draft of a form. The user clicks on "save draft" then a popup appears and the user put the name of the draft them I save the draft with the name.
One problem is that with <rich:modalPanel> I need to have a separate form for the modal panel. But I need to submit both forms. How I do that?
I succeed to submit the main form by placing the modal panel inside the main form, but then the draft name is not set in the managed bean variable. Theres a way of getting the name and send to the bean trough javascript? I already tried setPropertyActionListener and f:param with value=”javascript:document.getElementByID('nome_rascunho').value” with no success.

The other problem is that before show the modal panel I need to validate if the user give at least one information so I can save it on the draft. But I couldn't succeed on make a condition in which I call a managed bean method to validate this, then show the modal panel only if the method succeeds. If the method fails I need to show a message to the user saying that he must fill at least one field. The call to the managed bean on the IF part of onclick="if (#{tipoDocHabilMB.salvarRascunho}) #{rich:component('modal_salvar_rascunho')}.show()" is called only when the component is rendered, not when the user clicks on it. Any suggestions?

The code is bellow. I omitted part of the main form. As you see theres a <a4j:form> but I already tried the <h:form> as well. Also I know that I must have the modal panel on its own panel, but them I need to submit both forms. The strange words are in Portuguese, where rascunho = draft



thanks for listening
Aurelian Tutuianu
Ranch Hand

Joined: May 13, 2004
Posts: 86
At line 16 didn't you should have also the value attribute? Perhaps this is why you don't receive a value for nome_rascunho.
Using value attribute you create a binding between the property of the managed bean and the input text control.

http://javasign.blogspot.com/
Juliano Sott
Greenhorn

Joined: Jul 13, 2009
Posts: 3
Aurelian Tutuianu wrote:At line 16 didn't you should have also the value attribute? Perhaps this is why you don't receive a value for nome_rascunho.
Using value attribute you create a binding between the property of the managed bean and the input text control.

Yes, I did it before, but I modified to set the value "teste" on line 21 thought the <f:setPropertyActionListener. I also tried to use a valueChageListener on the inputText, but the method was not called. Sorry for post the code in the current state. Tomorrow I will post the code that I think should work but it doesn't.>
Annu Vinayak
Greenhorn

Joined: Jul 17, 2009
Posts: 19
You said you wanted to open a modal panel after having validated the main form. Thats pretty simple actually. You can use the Commons Validator framework for this. You can define the validation rules in an xml file. The form will get submitted only after the validation rules have been fulfilled.
Also, if you want to do the validations in your backing bean, then do the validations in the action method. If the validation succeeds, set a class level variable to true. Then in the modal panel, set the "showWhenRendered" property to true when the variable has that value.

Eg: <rich:modalPanel id="excldStatesPanel" width="650" height="500" top="20" showWhenRendered="#{createBean.renderScreen}">

I hope this helps!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Troubles with rich:modalPanel