Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7991089
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T13:11:44+00:00 2026-06-04T13:11:44+00:00

The button invoke the action method only when in the JSF view I delete

  • 0

The button invoke the action method only when in the JSF view I delete JSTL code, I know that it is abour lifecycle but I dont understand the cause/problem. I like to comprime because it ocurrs this behavior.

view code work fine

    <f:metadata>            
<f:viewParam name="idAsociacion" value="#{msgUsuario.asociacion}" converter="#
               {asociacionConverter}"
        converterMessage="#msg['aplicacion.asociacion.error.converter']}" required="true" 
        requiredMessage="#{msg['aplicacion.asociacion.error.required']}" />
<f:viewParam name="idMsg" value="#{msgUsuario.mensajeRespondido}" converter="#
     {mensajeConverter}" converterMessage="#{msg['aplicacion.mensaje.error.converter']}" 
     required="true" requiredMessage="#{msg['aplicacion.mensaje.error.required']}" />
    </f:metadata>

    <ui:decorate template="/WEB-INF/templates/mainUsuario-template.xhtml">
    <ui:define name="title">        
    <h:outputFormat value="#{msg['usuario.escribirMsj.title']}">
        <f:param value="#{msgUsuario.asociacion.nombre}" />
    </h:outputFormat>
    </ui:define>

    <ui:param name="descripcionView" value="#{msg['usuario.escribirMsj.descripcion']}" />

     <ui:define name="content">
<h:panelGroup layout="block"
          id="escribirMensajeContainer"styleClass="escribirMensajeContainer">
    <h:form>
        <p:panelGrid>
        <p:row>
        <p:column>
        <h:outputLabel for="texto" value="#{msg['usuario.escribirMsj.mensaje']}" 
                 styleClass="labelInput" />
        </p:column>
        </p:row>

        <p:row>
        <p:column>
        <p:inputTextarea  autoResize="true" cols="80" rows="15" id="texto" 
             maxlength="500" value="#{msgUsuario.texto}">

        </p:inputTextarea>
            </p:column>
        </p:row>

        <p:row>
    <p:column>
    <h:message for="texto" id="messageMensajeError" styleClass="messageError" />
    </p:column>                         
        </p:row>


        <p:row>         
             <p:column>
    <p:commandButton action="#{msgUsuario.enviar}" 
               alt="#{msg['usuario.escribirMsj.alt.enviar']}" tabindex="2" title="#
      {fn:replace(msg['usuario.escribirMsj.title.enviar'],0,msgUsuario.asociacion.nombre)}" 
       value="#{msg['usuario.escribirMsj.enviar']}" />
</p:column>                         
    </p:row>                            
    </p:panelGrid>
    </h:form>
    </h:panelGroup>         
    </ui:define>
    </ui:decorate>
    </html>

But if I add JSTL how I show below. The view render fine because the message is not responsed but the button never invoke the action method and the view reload.

      <c:choose>
      <c:when test="#{msgUsuario.mensajeRespondido.respondido==false}">
        <h:form>
        <p:panelGrid>
        <p:row>
        <p:column>
        <h:outputLabel for="texto" value="#{msg['usuario.escribirMsj.mensaje']}" 
                 styleClass="labelInput" />
        </p:column>
        </p:row>

        <p:row>
        <p:column>
        <p:inputTextarea  autoResize="true" cols="80" rows="15" id="texto" 
             maxlength="500" value="#{msgUsuario.texto}">

        </p:inputTextarea>
            </p:column>
        </p:row>

        <p:row>
    <p:column>
    <h:message for="texto" id="messageMensajeError" styleClass="messageError" />
    </p:column>                         
        </p:row>


        <p:row>         
             <p:column>
    <p:commandButton action="#{msgUsuario.enviar}" 
               alt="#{msg['usuario.escribirMsj.alt.enviar']}" tabindex="2" title="#
      {fn:replace(msg['usuario.escribirMsj.title.enviar'],0,msgUsuario.asociacion.nombre)}" 
       value="#{msg['usuario.escribirMsj.enviar']}" />
</p:column>                         
    </p:row>                            
    </p:panelGrid>
    </h:form>
    </c:when>
    <c:otherwise>
         <h:outputText value="MESSAGE RESPONSED" />
    </c:otherwise>
    </c:choose>

Note: Converts work fine in two case.

ManagedBean code

  @ManagedBean(name="msgUsuario")
  @ViewScoped
  public class EscribirMensajeUsuarioView implements Serializable {

private static final long serialVersionUID = 1L;
private static final Logger logger=Logger.getLogger(EscribirMensajeUsuarioView.class);

private Asociacion asociacion;

private Mensaje mensajeRespondido;

private Usuario usuario;


private String texto;

private boolean usuarioBloqueado;

@ManagedProperty(value="#{mensajeBO}")
private MensajeBO mensajeBo;

@ManagedProperty(value="#{usuarioBO}")
private UsuarioBO usuarioBo;


/* Never invoked with JSTL code in the view */

public String enviar(){
    logger.info("EscribirMensajesUsuarioView.enviar");

    TipoMensaje tipoMensaje=null;
    Mensaje mensaje=this.mensajeRespondido;

    .................
            .................
            .................
      }


/* Getters and Setters */
   }

I read this Balusc’s comment

“JSF and JSTL doesn’t run in sync as you’d expect from the coding. JSTL runs during build time of the view (when the JSF component tree is to be populated) and JSF runs during render time of the view component tree (when HTML output is to be generated). You can visualize it as follows: JSTL runs first from top to bottom and then hands over the result to JSF which in turn runs from top to bottom again.”

I understand this in dinamyc datatable for example, but not in this case. Because JSTL render fine the view being that mensajeRepetido exit in the JSF tree, but button doesnt invoke the method.However the view reload and mensajeRepetido exits again by the converter.

Kind regards.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T13:11:46+00:00Added an answer on June 4, 2026 at 1:11 pm

    Your problem is caused because you’re binding JSTL attributes to a view scoped managed bean property. This works only if partial state saving is turned off. With partial state saving turned on (as by default), JSTL attributes gets its own second instance of the view scoped bean (with all properties set to default!) and not the instance which is stored in JSF view state and is been used by JSF components.

    Just use JSF component’s rendered attribute instead the usual way and use JSTL only to control the building the view, not to control the rendering of the view.

    <h:form rendered="#{not msgUsuario.mensajeRespondido.respondido}">
        ...
    <h:form>
    <h:panelGroup rendered="#{msgUsuario.mensajeRespondido.respondido}">
         <h:outputText value="MESSAGE RESPONSED" />
    </h:panelGroup>      
    

    See also:

    • JSTL in JSF2 Facelets… makes sense?
    • Communication in JSF 2.0 – @ViewScoped fails in taghandlers
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a button that when i tap on it i want to invoke
Code: button.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { // fileReader(); new xyz().execute(); }//
Today I'd like to know some features on the JSF Lifecycle. Let me start
I have this code: Button give_review = (Button)findViewById(R.id.give_review); give_review.setOnClickListener(new Button.OnClickListener() { public void onClick(View
I have a button that when clicked will run a stored procedure on a
I need a button-like control that can have a Checked property, so that when
I have a hidden button on a form that I need to click in
My result tables/images will be displayed in the same page. But the submit button
I have an app that has a UINavigationController that pushes a UITabBarController into view.
I have following sample code. Initially, only commandButton Two is visible. When I click

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.