I want to insert outputText in the value attribute of a commandButton. The problem I am facing here is that the 'value' attribute of the commandButton only takes static text as value but I want this text to change according to the value assigned to that list and the whole value should be displayed inside the commandbutton.
<h:commandButton id="submit-button" styleClass="click_button1"
type="submit" value="Yes"
action="#{xyz.deleteAction(o)}" update="msgs" />
In this, instead of "yes", I want something like this
Yes, I want this thing <h:outputText size="15" value="#{o.name}" /></b> from <h:outputText size="15" value="#{o.detals}" /></b>
as the value.
If you really need some h:outputText
features such as escape="false"
then your best bet is to use h:commandLink
instead. You may need to tweak your CSS if you want to get a look and feel close to h:commandButton
.
<h:commandLink id="submit-button" styleClass="click_button1" action="#{xyz.deleteAction(o)}" update="msgs">
Yes, I want this thing <h:outputText value="#{o.name}" /> from <h:outputText value="#{o.detals}" />
</h:commandLink>
If you only need to display some dynamic values then you can perfectly use an EL expression
<h:commandButton id="submit-button" styleClass="click_button1" type="submit" value="Yes, I want this thing #{o.name} from #{o.detals}" action="#{xyz.deleteAction(o)}" update="msgs" />
See also Is it suggested to use h:outputText for everything?
Notes:
</b>
tags from your example as this looks like a typo from me.h:outputText
doesn't have a size
attribute.Edited following Kukeltje and BalusC's comments.