So I want to share custom text to WhatsApp on the press of a button. So far I have used the href tag to redirect me to the WhatsApp page but the text needs to be put in the url itself. I'm looking for a way to generate custom URLs in my href tag. This is what I have now:
<p:button value="Share to WhatsApp" target="_blank" href="https://api.whatsapp.com/send?text=Static text!"
icon="fab fa-whatsapp" styleClass="ui-button-outlined"/>
And I want to implement something like
<p:button value="Share to WhatsApp" target="_blank" href="#{getUrlWithCustomText()}"
icon="fab fa-whatsapp" styleClass="ui-button-outlined"/>
where the function getUrlWithCustomText() can be something like
public String getUrlWithCustomText(String customText)
{
return "https://api.whatsapp.com/send?text="+customText;
}
But href does not support expression language. I cannot use javascript for this project so I need a solution in Java. Any help is appreciated!