开发者

Length of h:outputLabel changes after RichFaces AJAX call

I have been trying to incorporate RichFaces into one of our more complicated pages to make it run a bit more smoothly via AJAX. Everything is working fine and it has solved a few problems I was having using regular form posts so I'd really like to keep it. The only problem in my way is that after pressing an a4j:commandButton most of my h:outputLabels are shortened by 3 pixels (these pixels were to the left of the text, which is unusual since the left padding, margin and border width are all 0px). This causes lots of my controls to shift slightly and looks very unprofessional. It looks to me like the re-rendering has done a more accurate job than the initial render. Here are the relevant parts of my page:

<a4j:form id="mainForm">
    ...
    <fieldset id="illustrationDetails">
        <h:outputLabel for="product" value="Product" />
        <h:selectOneMenu id="product" value="#{illustrationManager.illustration.product}" valueChangeListener="#{illustrationManager.illustration.setProduct}" onchange="submit()">
            <f:selectItems value="#{illustrationManager.illustration.products}" />
        </h:selectOneMenu>
        <h:outputLabel for="paymentFrequency" value="Payment" />
        <h:selectOneMen开发者_开发知识库u id="paymentFrequency" value="#{illustrationManager.illustration.paymentFrequency}">
            <f:selectItems value="#{illustrationManager.illustration.paymentFrequencies}" />
        </h:selectOneMenu>
        <h:outputLabel for="expenseGroup" value="Expense Group" />
        <h:selectOneMenu id="expenseGroup" value="#{illustrationManager.illustration.expenseGroupId}">
            <f:selectItems value="#{illustrationManager.illustration.expenseGroups}" />
        </h:selectOneMenu>
    </fieldset>
    ...
    <a4j:commandButton id="calculateButton" value="Calculate" action="#{illustrationManager.calculatePremium()}" ajaxSingle="true" reRender="mainForm" />
    ...
</a4j:form>

In the fieldset above, all but the first label exhibit this problem. The first label is rendered what I would consider to be correctly (with no pixels to the left) by the initial render and as a result is not changed by the re-render.

Any suggestions would be welcome! Also, if you want more info like the css for the relevant controls let me know and I'll post it.


Well, this is a partial answer anyway. The 3 pixels to the left of the h:outputLabels was due to the fact that the Mojarra JSF implementation adds a \n character to the beginning of the label tag body it creates. I'm as baffled as the guy who submitted this bug about it as to why this is done. The \n is converted to a space when displayed and that's what my 3 pixels were.

I do not know why, but the re-render triggered by my RichFaces AJAX call removes these \n characters and so the space is no longer displayed.

As a workaround, I have explicitly put spaces at the front of all my labels so that a space is always displayed. I'm surprised this is not a common problem.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜