0

i included one template with an generic id

<ui:include src="./buttons.xhtml">
     <ui:param name="action" value="#{bean.nextSessionId()}" />
</ui:include>

buttons.xhtml

<ui:composition>
   hello-#{action}-#{action}
</ui:composition>

output

hello-obcpusp90m7653vci7ohh87aa3-vcv63aj2h8h8gak3dhb5do0

the bean is viewscoped

private SecureRandom random = new SecureRandom();

public String nextSessionId()
{
   return new BigInteger(130, random).toString(32);
}

why the id not equals?

i need the id for this

<p:commandButton id="basic#{action}" value="Basic" onclick="dlg1#{action}.show()" type="button" process="@this"/>


<p:confirmDialog id="id#{action}" widgetVar="dlg1#{action}">  
    <p:inputText value="....."/>

    <p:commandButton oncomplete="dlg1#{action}.hide()" value="Close"/>
</p:confirmDialog>  
user1181110
  • 57
  • 1
  • 7

1 Answers1

0

Do not do business logic in getter methods. Getter methods are supposed to return already-prepared bean properties. The lifespan of the property is supposed to be idenfitied by the scope of the managed bean holding the property, which can be none, request, view, session or application scoped.

E.g.

private String sessionId;

@PostConstruct
public void init() {
    SecureRandom random = new SecureRandom();
    sessionId = new BigInteger(130, random).toString(32);

public String getSessionId() {
    return sessionId;
}

with

<ui:param name="action" value="#{bean.sessionId}" />

Note that I also fixed the completely wrong method name.

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555