문제

Here is my code. When I click the link Comment, a inputTextarea and commandButton suppose to appear

    <h:outputLink id="link" value="javascript:void(0)">
            <h:outputText value="Comment"/>
            <p:effect type="fade" event="click" for="reply">
                <f:param name="mode" value="'show'"/>
            </p:effect>
        </h:outputLink>
        <h:panelGrid id="reply" style="display:none;">
            <h:inputTextarea id="keyword" rows="2" /> &nbsp;                
        </h:panelGrid>
    </h:outputLink>

When I click on the link, nothing seem to happen, nothing appear. Any idea. I run this on Glassfish. The showcase from primeface.org is running under Tomcat.

도움이 되었습니까?

해결책

There are two problems:

First, according to the PrimeFaces User Guide the appear effect is not supported.

Following is the list of effects supported by PrimeFaces.

  • blind
  • clip
  • drop
  • explode
  • fold
  • puff
  • slide
  • scale
  • bounce
  • highlight
  • pulsate
  • shake
  • size
  • transfer

So change the p:effect to:

<p:effect type="blind" event="click" for="reply">
    <f:param name="mode" value="'show'" />  
</p:effect>

Second, the generated source of the link tells the following:

<a href="javascript:void(0)">Comment<script type="text/javascript">
YAHOO.util.Event.addListener('j_idt6:j_idt7', 'click', function(e) {
  jQuery(PrimeFaces.escapeClientId('j_idt6:reply')).effect('blind',{mode:'show'},1000);
});</script></a>

The client ID j_idt6:j_idt7 doesn't appear anywhere in the source. It has to be the link itself. So adding an id to the h:outputLink should fix it. Look like a bug in PrimeFaces.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top