3 Replies Latest reply: Dec 15, 2009 5:28 PM by Nick Belaevski RSS

What about switchType=ajax on modalPanels ?

gonzalad Apprentice

Hello,

 

Lately, I'm mostly (80% of times) rendering my rich:modalPanels in ajax mode [1] :

- a4j:commandButton calls a backing bean method, and rerenders the a4j:outputPanel surrounding  rich;modalPanel.

     oncomplete js handler call Richfaces.showPanel.

- the rich:modalPanel is inside a a4j:outputPanel nd its rendered attribute points to a backing bean property.

 

This is because each modalPanels weights more or less 5 ko (I've seen 4 different application and it was always at least 5 ko).

This code is repetitive.

 

Could it be possible to add a switchType attribute on rich:calendar, the meaning of which would be :

  1. if switchType=client, behaviour unchanged.
  2. if switchType=ajax, Richfaces.showModal would make an ajax call, rerender the rich:modalPanel (so rich:modalPanel would always be contained in an invisible <span> or shting like this) and show it.

 

When Richfaces.hideModalPanel is called, there would be no ajax call (we're never rerendering the modalPanel on close, saving a server round trip).

 

So, with switchType="ajax", the following code :

 


<rich:panel>
  <h:form>
    ...
    <a4j:commandLink action="#{orderEntryController.createProperty}"
      value="Add a property" reRender="propertyDialogPanel"
      oncomplete="Richfaces.showModalPanel('propertyDialog')"/>
    ...
 </h:form>
</rich:panel> ...
<a4j:outputPanel id="propertyDialogPanel" layout="inline">
  <rich:modalPanel id="propertyDialog" width="400" height="400">
    <f:facet name="header">Edit property</f:facet>
    <h:form>
      <p>Hello world</p>
      <p><a href="javascript:Richfaces.hideModalPanel('propertyDialog')">Cancel</a></p>
    </h:form>
  </rich:modalPanel>
</a4j:outputPanel>

 

 

 

Could be changed to :

<rich:panel>
  <h:form>
    ...
    <a4j:commandLink action="#{orderEntryController.createProperty}"
       value="Add a property" onclick="Richfaces.showModalPanel('propertyDialog')"/>
    ...
  </h:form>
</rich:panel>
...
<rich:modalPanel id="propertyDialog" switchType="ajax" width="400" height="400">
  <f:facet name="header">Edit property</f:facet>
  <h:form>
    <p>Hello world</p>
    <p><a href="javascript:Richfaces.hideModalPanel('propertyDialog')">Cancel</a></p>
  </h:form>
</rich:modalPanel>

 

One caveat though, when I call Richfaces.showModal in my a4j:commandLink would it post the surrounding form (bad bad !).

 

What do you think ?