• Post Reply Bookmark Topic Watch Topic
  • New Topic

Need to refresh page to get updated value from java beans  RSS feed

 
Vjm Mak
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I want latest value of variable in my jsp page. I tried following things but unable to get update value in JSP page.

My Action Class:

public class MyAction extends Action{

    if(myCondition){
        ReportBean.setNOTIFY(true);                
    } else {               
        ReportBean.setNOTIFY(false);
    }
}

Bean Class:
public class ReportBean {

public static boolean NOTIFY = true;

public static boolean isNOTIFY() {
    return NOTIFY;
}

public static void setNOTIFY(boolean NOTIFY) {
    this.NOTIFY = NOTIFY;
}
}

JSP:

<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ page import="com.uks.its.zz1_zzz01.form.Notify" %>
<%@ taglib prefix="html"
uri="http://jakarta.apache.org/struts/tags-html"%>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-bean"
prefix="bean"%>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-logic"
prefix="logic"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>

<script>
$(document).ready(function() {                       
$('#submit').click(function(event) { 
    var nft=$('#NOTIFY').val();
        $.get('MyAction',{NOTIFY:nft},function(responseText) {
        $('#restrict-id').text(responseText);        
        });
    });
});
</script>

value = ${nft} 

<c:if test="${nft eq true}">                                   
<div class="col-lg-4" id="restrict-id">
<div class="panel panel-default">
<div class="panel-heading">

</div>
<div class="panel-body">

</div>
</div>
</div>
</c:if>

We are using struts in our application.

I get value in "Const" but it is not updated value. Need to refresh my page two times to get updated value. But in our page we have set that any refresh will logout user from application. So, how i get that value in JSP page. What type of changes required in this code.

What are the changes required in this code. Thanks in advance.
 
Vjm Mak
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Vimal Makwana wrote:I want latest value of variable in my jsp page. I tried following things but unable to get update value in JSP page.

My Action Class:

public class MyAction extends Action{

    if(myCondition){
        ReportBean.setNOTIFY(true);                
    } else {               
        ReportBean.setNOTIFY(false);
    }
}

Bean Class:
public class ReportBean {

public static boolean NOTIFY = true;

public static boolean isNOTIFY() {
    return NOTIFY;
}

public static void setNOTIFY(boolean NOTIFY) {
    this.NOTIFY = NOTIFY;
}
}

JSP:

<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ page import="com.uks.its.zz1_zzz01.form.Notify" %>
<%@ taglib prefix="html"
uri="http://jakarta.apache.org/struts/tags-html"%>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-bean"
prefix="bean"%>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-logic"
prefix="logic"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>

<script>
$(document).ready(function() {                       
$('#submit').click(function(event) { 
    var nft=$('#NOTIFY').val();
        $.get('MyAction',{NOTIFY:nft},function(responseText) {
        $('#restrict-id').text(responseText);        
        });
    });
});
</script>

value = ${nft} 

<c:if test="${nft eq true}">                                   
<div class="col-lg-4" id="restrict-id">
<div class="panel panel-default">
<div class="panel-heading">

</div>
<div class="panel-body">

</div>
</div>
</div>
</c:if>

We are using struts in our application.

I get value in "Const" but it is not updated value. Need to refresh my page two times to get updated value. But in our page we have set that any refresh will logout user from application. So, how i get that value in JSP page. What type of changes required in this code.

What are the changes required in this code. Thanks in advance.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!