0

What could possible reasons be that my action calls are delayed? It happens for all action calls on one form I have. After I click on a anything that will call an action (or when the value of a dataTable should be evaluated on form load), it takes roughly 10 seconds for the action to be called. (I checked it by setting a breakpoint and then click on the button.)

Any ideas why?

This is the part that seems to cause the trouble:

<h:panelGroup id="someGroup">
<h:dataTable value="#{someHandler.keys}" binding="#{someHandler.dataTable}" var="key">
    <h:column>
        <f:facet name="header">
            <h:outputText value="Key" />
        </f:facet>
        <h:outputText value="#{key}" />
    </h:column>
    <h:column>
        <f:facet name="header">
            <h:outputText value="Value" />
        </f:facet>
        <h:commandLink value="[No value]" rendered="#{empty someHandler.getValue(key)}">
            <f:ajax listener="#{someHandler.loadProperty}" render="someForm:key someForm:value" />
        </h:commandLink>
        <h:commandLink value="#{someHandler.getValue(key)}" rendered="#{not empty someHandler.getValue(key)}">
            <f:ajax listener="#{someHandler.loadProperty}" render="someForm:key someForm:value" />
        </h:commandLink>
    </h:column>
</h:dataTable>
</h:panelGroup>

During debugging I noticed that it always calls someHandler.keys first when I click a commandLink. Is there any explaination for that? I don't want the dataTable rerendered if I click on one of these commandLinks. None of the methods called is particularly "slow".

geeehhdaa
  • 822
  • 5
  • 17
  • 30
  • 1
    Are you using any component library? Does this also occur on a very minimal page with only a form and a button and a backing bean with only an action method? – BalusC May 24 '11 at 12:13
  • It only happens with one form. I can point out with part causes it if I remove it, but the part itself is not harmful. If I click an action in that part, it takes 10 seconds for the action to be invoked. I'm using Tomahawk (not in this form). I have a bunch of commandLinks displayed in a dataTable and they all happen to have this "you have visited me"-color now. (They hadn't before!) If I change the commandLinks to commandbuttons, it stays the same. – geeehhdaa May 26 '11 at 14:12
  • Then you need to show the code and point out the part which caused the problem. As to the visited CSS, that can be true since JSF POST forms submits to the same page as you're currently viewing and the browsers only mark a link as visited if the URL is present in the browser history. You probably just want GET links using `h:outputLink`. – BalusC May 26 '11 at 14:14
  • I added the snippet of the form. Dank u wel! – geeehhdaa May 26 '11 at 16:01

2 Answers2

1

The only feasible explanation I can think of is that you're doing expensive business logic inside a getter method instead of in the bean's constructor or any other event method which is called only once when necessary.

Getter methods are intented to only return some prepopulated bean property or at highest do lazy loading, not to do expensive business logic like connecting a DB, copying 1000 rows into Java's memory, etcetera. Getter methods can be called more than once during a JSF request, which grows exponentially when the call is made inside an iterating component like <h:dataTable> or is been used in rendered attribute. JSF/EL won't cache results of getter methods on a per-request basis or something since a normal getter call is prarticularly cheap.

See also:

Community
  • 1
  • 1
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
  • The getters should not be the problem. I noticed it takes ~ 5 seconds for Firefox to render the source code of the page, even though it's only ~ 250 lines. It's way faster for every other xhtml-file. I guess that means that something's wrong with the generated html-code? Is there any way I can find out what's wrong? – geeehhdaa May 31 '11 at 14:52
0

I'd say your browser is having a hard time with the "lousy" javascript generated by JSF. Did you measure performances with different browsers ? I suggest seeing if chrome for example goes faster.

jonasr
  • 1,876
  • 16
  • 18
  • Thanks for the guess, it takes as long in IE too. I'll check out if it's faster in Chrome, but I doubt it. The form isn't very sophisticated/big either. :( – geeehhdaa May 24 '11 at 12:13