RichFaces rich:clientId within facelets

[亡魂溺海] 提交于 2019-12-11 06:04:42

问题


I'm trying to something like this:

<?xml version="1.0"/>
<ui:composition ....>
    <h:inputText id="#{id}InputText" value="#{value}"/>

    <rich:calendar id="#{id}Shevron"
        popup="true"
        datePattern="ddMMyy"
        showInput="false" 
        todayControlMode="hidden"
        enableManualInput="false"
        showApplyButton="false"
        updateDays="14"
        ondateselected="alert('#{rich:clientId('#{id}Shevron')}');"
        inputClass="xwingml-input"/>
</ui:composition>

The problem I'm facing here is that the actual client id is generated for my facelts components. Is there a way to pass an id to rich:clientId like this? If not how would one go about this kind of problem?

Thanks in advance!.


回答1:


All rich:clientId does it to render document.getElementById() and provide the full id.

So don't use #{rich:clientId('#{id}Shevron')} and just use document.getElementById('#{id}Shevron'); and ensure that you specify the full ID (ie. including the form ID etc)




回答2:


An old question, but here I write down my solution in case it helps someone.

You can pass parameters to JSTL functions without needing the evaluation operators ( #{} ${} ). Take a look at this String length example.

So if your "id" wasn't dynamically generated this will solve your problem:

#{rich:clientId(id)}

But in your case you need to define an additional variable to store your dynamic id:

<c:set var="myDynamicID" value="${id}Shevron"/>

And then use it to obtain the client UI.

#{rich:clientId(myDynamicID)}


来源:https://stackoverflow.com/questions/2956983/richfaces-richclientid-within-facelets

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!