i am quite new at this and i what to know how can i get a index row from a dynamical table created with struts2. Here is what i have tried so far:
test file
<table class="table table-bordered table-striped table-condensed table-hover"
id="exp">
<thead>
<tr>
<th class="center"></th>
<th>Name</th>
</tr>
</thead>
<tbody>
<s:if test="listanume.size>0">
<s:iterator value="listanume" status="statusVar">
<tr>
<td class="center">
<button class="btn" onclick="javascript:setval(0)">
delete
</button>
</td>
<td><s:property value="nume"/></td>
</tr>
</s:iterator>
</s:if>
</tbody>
</table>
<h4>Numarul randului este: <s:property value="mysample"/> </h4>
<script>
var mysample= '';
function= setval(varval){
mysample=varval;
alert(mysample);
}
</script>
pop java
public class Pop {
private int nrrow;
private List<UserModel> listanume = new ArrayList<UserModel>();
UserModel user = new UserModel(),
user1 = new UserModel(),
user2 = new UserModel();
private String[] sample;
{
sample = new String[]{"list1", "list2", "list3"};
}
public String execute() {
user.setEmail("eret#esre");
user.setPass1("1234");
user.setNume("gigel");
user1.setEmail("yuii#ihj");
user1.setPass1("6789");
user1.setNume("marius");
user2.setEmail("nmnn#cvx");
user2.setPass1("7676");
user2.setNume("sorin");
sample1.add(user);
sample1.add(user1);
sample1.add(user2);
return "succes";
}
public String afisnrow(){
execute();
listanume=sample1;
return "succes";
}
public String[] getSample() {
return sample;
}
public void setSample(String[] sample) {
this.sample = sample;
}
public List<UserModel> getSample1() {
return sample1;
}
public void setSample1(List<UserModel> sample1) {
this.sample1 = sample1;
}
public void setNrrow(int nrrow){
this.nrrow=nrrow;
}
public int getNrrow(){
return nrrow;
}
public List<UserModel> getListanume(){
return listanume;
}
public void setListanume(List<UserModel> listanume){
this.listanume=listanume;
}
}
every row has a button on it and when i click that button i need to get the row index, i kind of stuck and run out of ideas, any suggestions?
replace
onclick="javascript:setval(0)"
with
onclick="javascript:setval(<s:property value="#statusVar.index" />)"
more info on the struts2 iterator tag here.
The solution i have found is this:
test file
<table class="table table-bordered table-striped table-condensed table-hover"
id="exp">
<thead>
<tr>
<th class="center"></th>
<th>Name</th>
</tr>
</thead>
<tbody>
<s:if test="listanume.size>0">
<s:iterator value="listanume" status="statusVar">
<tr>
<td class="center">
<button class="btn" id="<s:property value='indexrow'/>">
delete
</button>
</td>
<td><s:property value="nume"/></td>
</tr>
</s:iterator>
</s:if>
</tbody>
</table>
<i><p id="test"> No button pressed.</p></i>
<script>
$("button").click(function(e){
var idClicked = e.target.id;
$("#test").html(idClicked);
});
</script>
pop java
public class Pop {
private int indexrow;
private List<UserModel> listanume = new ArrayList<UserModel>();
UserModel user = new UserModel(),
user1 = new UserModel(),
user2 = new UserModel();
public String execute() {
user.setEmail("eret#esre");
user.setPass1("1234");
user.setNume("gigel");
user1.setEmail("yuii#ihj");
user1.setPass1("6789");
user1.setNume("marius");
user2.setEmail("nmnn#cvx");
user2.setPass1("7676");
user2.setNume("sorin");
listanume.add(user);
listanume.add(user1);
listanume.add(user2);
return "succes";
}
public String afisnrow(){
execute();
for (UserModel userModel : listanume) {
UserModel userModel1=new UserModel();
indexrow++;
userModel1.setNume(userModel.getNume());
userModel1.setIndexrow(indexrow);
listanume.add(userModel1);
}
return "succes";
}
public List<UserModel> getListanume(){
return listanume;
}
public void setListanume(List<UserModel> listanume){
this.listanume=listanume;
}
}
Related
Help me please to remove the row in Postgres by clicking the Del button.
Maybe to link id in DB and id on the HTML page, but how?
Maybe I need to parse the HTML page and pass String id?
Any ideas will help me.
here is my database schema:
<table class="tmc">
<thead>
<tr>
<th>ID</th><th>TMC</th><th>SN</th><th>Owner</th>
</tr>
</thead>
<tbody>
{{#messages}}
<tr>
<td>{{id}}</td>
<td><span>{{text}}</span></td>
<td><i>{{sn}}</i></td>
<td><i>{{owner}}</i></td>
<th><form action="/remove" method="post">
<input type="submit" value="Del"/>
<input type="hidden" name="_csrf" value="{{_csrf.token}}" />
</form>
</th>
</tr>
{{/messages}}
</tbody>
#Entity
#Table(name = "message")
public class Message {
#Id
#GeneratedValue(strategy=GenerationType.AUTO)
private Integer id;
private String text;
private String sn;
private String owner;
public Message() {
}
public Message(String text, String sn, String owner) {
this.text = text;
this.sn = sn;
this.owner = owner;
}
Rows are forming in database by:
#PostMapping("/main")
public String add (
#RequestParam String owner,
#RequestParam String text,
#RequestParam String sn, Map<String, Object> model) {
Message message = new Message (text, sn, owner);
if (text != null && !text.isEmpty() & sn != null && !sn.isEmpty() & owner != null &&
!owner.isEmpty()) {
if (!text.matches("^[0-9].*$")) {
messageRepo2.save(message);
Iterable<Message> messages = messageRepo2.findAll();
model.put("messages", messages);
} else
model.put("error", "ТМЦ не должно начинаться с цифры");
Iterable<Message> messages = messageRepo2.findAll();
model.put("messages", messages);
} else {
model.put("error", "Заполните все поля!");
Iterable<Message> messages = messageRepo2.findAll();
model.put("messages", messages);
}
return "main";
}
There are two issues with your html code:
it would be to let the form element outside the table
need to use <input type="hidden" name="xxx" value="{{xxx}}" /> in order to let it can pass parameter to your controller method
<form action="/remove" method="post">
<input type="hidden" name="_csrf" value="{{_csrf.token}}" />
<table class="tmc">
<thead>
<tr>
<th>ID</th><th>TMC</th><th>SN</th><th>Owner</th>
</tr>
</thead>
<tbody>
{{#messages}}
<tr>
<td>{{id}} <input type="hidden" name="id" value="{{id}}" /></td>
<td><span>{{text}}</span></td>
<td><i>{{sn}}</i> <input type="hidden" name="sn" value="{{sn}}" /></td>
<td><i>{{owner}}</i> <input type="hidden" name="owner" value="{{owner}}" /></td>
<td><input type="submit" value="Del"/></td>
</th>
</tr>
{{/messages}}
</tbody>
</table>
</form>
<thead>
<tr>
<th>ID ТМЦ</th><th>Наименование ТМЦ</th><th>Серийный номер ТМЦ</th><th>За кем числится</th>
</tr>
</thead>
<tbody>
{{#messages}}
<tr>
<td>{{id}}</td>
<td><span>{{text}}</span></td>
<td><i>{{sn}}</i></td>
<td><i>{{owner}}</i></td>
<td>
<form action="/remove" method="post" name="remove">
<input type="submit" value="Удалить"/>
<input type="hidden" name="_csrf" value="{{_csrf.token}}" />
<input type="hidden" name="sn" value="{{sn}}"/>
</form>
</td>
</tr>
{{/messages}}
</tbody>
import com.example.webapp.domain.Message;
import org.springframework.data.repository.CrudRepository;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
#Transactional
public interface MessageDel extends CrudRepository<Message, Long>{
List<Message> deleteBySn (String sn);
}
#PostMapping("/remove")
public String remove (#RequestParam String sn, Map<String, Object> model) {
Message messagedel = new Message (sn);
messageDel.deleteBySn(sn);
model.put("messages", messagedel);
return "redirect:/main";
}
I have a page that show all lists from "dataLansia" table. Like this one :
http://i61.tinypic.com/fliwcm.jpg
And then, I want to make a little improvement. When I pick a date from that date input and I press 'Cari' button, the page show me only the result from 'dataLansia' table where the attribute of 'Tanggal Data' match with the date I pick before. How to do that ?
Here's my stuff (controller, model, view) :
public class Application extends Controller {
//the other code
public static void rekap(){
List rekapProfil=dataLansia.findAll();
render(rekapProfil);
}
}
public class dataLansia extends Model{
public String tensi;
public int guladarah;
public int kolesterol;
public double asamurat;
#Unique
public java.util.Date tglData;
#Lob
public String keluhan;
#ManyToOne(cascade=CascadeType.ALL)
public potensi lans;
#ManyToOne(cascade=CascadeType.ALL)
public lansia lansia;
}
public class lansia extends Model {
#Unique
public int idLansia;
public String namaLansia;
public int umur;
#Lob
public String alamat;
#OneToMany(mappedBy="lansia",cascade=CascadeType.ALL)
public Collection<dataLansia> dataLansia;
public String toString(){
return namaLansia;
}
}
#{extends 'Template/Dashboard.html' /}
#{set title:messages.get('rekap.title') /}
<div class="row">
<input type="date" name="rekapTgl.tglData.format('yyyy-MM-dd')" /> <input type="submit" class="btn btn-info" value="Cari" />
<table class="table table-bordered table-striped responsive">
<thead>
<tr>
<th class="text-center">Tanggal Data</th>
<th class="text-center">ID Lansia</th>
<th class="text-center">Nama Lansia</th>
<th class="text-center">Umur</th>
<th class="text-center">Alamat</th>
<th class="text-center">Tensi<br />(mmHg)</th>
<th class="text-center">Gula Darah<br />(mg/dL)</th>
<th class="text-center">Kolesterol<br />(mg/dL)</th>
<th class="text-center">Asam Urat<br />(mg/dL)</th>
<th class="text-center">Keluhan</th>
<th class="text-center">Potensi / Tidak Potensi</th>
</tr>
</thead>
<tbody>
#{list items:rekapProfil, as:'rD'}
<tr>
<td class="text-center">${rD.tglData.format('dd-MM-yyyy')}</td>
<td class="text-center">${rD.lansia.idLansia}</td>
<td class="text-center">${rD.lansia.namaLansia}</td>
<td class="text-center">${rD.lansia.umur}</td>
<td class="text-center">${rD.lansia.alamat}</td>
<td class="text-center">${rD.tensi}</td>
<td class="text-center">${rD.guladarah}</td>
<td class="text-center">${rD.kolesterol}</td>
<td class="text-center">${rD.asamurat}</td>
<td class="text-center">${rD.keluhan}</td>
<td class="text-center">${rD.lans.namaPotensi}</td>
</tr>
#{/list}
</tbody>
</table>
#{else}
<br /><center><b><i>Belum ada lansia terimunisasi.</i></b></center>
#{/else}
</div>
I want to get #Transient values from HTML.I had tried #Basic,it creates entry in db. I need to get this value.
Pojo:
#Transient
private int dueAmount;
public int getDueAmount() {
return dueAmount = this.getPaymentTotal() - this.getBillAmount() - this.getDiscountTotal();
}
public void setDueAmount(int dueAmount) {
this.dueAmount = dueAmount;
}
Controller
#RequestMapping(value="/billByPatientId/{id}", method = RequestMethod.GET)
public List<Bill> getBillsByPatientId(#PathVariable("id") String patientId)throws Exception {
List<Bill> BillDetailsByPatientId = billService.getBillsByPatientId(patientId);
for(Bill b : BillDetailsByPatientId){
System.out.println(b.getDueAmount());
}
return billService.getBillsByPatientId(patientId);
}
Js
$http.get('/bill/billByPatientId/'+patientData.id)
.success(function (data, status, headers, config) {
console.log(data)
$scope.bills = data;
});
HTML
<table data-ng-show='bills.length > 0' class="table table-hover">
<thead>
<tr>
<th class="col-lg-1 text-center">Bill No</th>
<th class="col-lg-3 text-center">Status</th>
</tr>
</thead>
<tr data-ng-repeat="bill in bills">
<td class="text-center">{{bill.billNo}}</td>
<td class="text-right">{{bill.dueAmount}}</td>
</tr>
In my current code i get " dueAmount " value because of printing " dueAmount " in my Controller, otherwise values will be null.
How to do this ?
I Referrer this document
Following contains the code inside my controller class , i am using the method public String getRegistrationForm(Map model) to return a jsp-page with a spring form on it , in this method i am setting userTab.setIsMfaEnabled(new Boolean(true)) , upon submitting the form the method :
public String registerUser(#ModelAttribute("user") UserTab user , BindingResult results , Map model)
is invoked as the handler method , but in this method the property 'isMfaEnabled' of user attribute set in the previous method is null and the line:System.out.println("user.getIsMfaEnabled() is nul"); is printing in the logs . Kindly tell me what is wrong here .
#Controller
#RequestMapping("/register")
public class RegisterUserController {
#Autowired
RegisterUserService registerUserService;
#RequestMapping(value = "/registeruser.action" , method = RequestMethod.POST)
public String registerUser(#ModelAttribute("user") UserTab user , BindingResult results , Map<String,Object> model){
System.out.println("executing regsiterUser ");
if(user == null)
System.out.println(", user is null");
if(results == null)
System.out.println("results is null");
UserTabValiator userTabValidator = new UserTabValiator();
if(user.getIsMfaEnabled() == null)
System.out.println("user.getIsMfaEnabled() is nul");
userTabValidator.validate(user, results);
if(results.hasErrors()){
return "registeruser";
}
try {
boolean val = registerUserService.isExistingUsername(user.getLoginName());
if(val){
System.out.println("username already exists");
model.put("message", "username already exists");
return "registeruser";
}
if(!val){
model.put("username", user.getLoginName());
model.put("message", "registration success ... ");
return "registrationsuccess";
}
} catch (Exception e) {
System.out.println("exception thrown");
e.printStackTrace();
return "errorpage";
}
return "errorpage";
}
#RequestMapping(value="/registeruser.view", method=RequestMethod.GET)
public String getRegistrationForm(Map<String,Object> model){
System.out.println("executing getRegistrationForm");
if(registerUserService == null)
System.out.println("register user service is null");
try{
ArrayList<MfaQuestion> allMfaQuestions = (ArrayList<MfaQuestion>) registerUserService.getAllMfaQuestions();
UserTab userTab = new UserTab();
userTab.setIsMfaEnabled(true);
model.put("user", userTab);
model.put("message", "register new user");
model.put("allMfaQuestions", allMfaQuestions);
return "registeruser";
}
catch(Exception e){
e.printStackTrace();
model.put("user", new UserTab());
model.put("message", "unable to get MFA questions");
return "registeruser";
}
}
}
UserTab Model Class :
package com.persistance.beans;
import java.util.Date;
public class UserTab {
private Integer userTabID;
private String loginName;
private String password;
private Date created;
private Date lastUpdated;
private Date lastLoginAttempt;
private Boolean isAccountLocked;
private Integer loginFailsNumber;
private Boolean isMfaEnabled;
private UserMfaMap userMfaMap;
public String toString(){
String str ="";
System.out.println("[userTabID , loginName , password");
return str;
}
public UserMfaMap getUserMfaMap() {
return userMfaMap;
}
public void setUserMfaMap(UserMfaMap userMfaMap) {
this.userMfaMap = userMfaMap;
}
public UserTab() {
super();
}
public String getLoginName() {
return loginName;
}
public void setLoginName(String loginName) {
this.loginName = loginName;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public Date getCreated() {
return created;
}
public void setCreated(Date created) {
this.created = created;
}
public Date getLastUpdated() {
return this.lastUpdated;
}
public void setLastUpdated(Date lastUpdated) {
this.lastUpdated = lastUpdated;
}
public Date getLastLoginAttempt() {
return lastLoginAttempt;
}
public void setLastLoginAttempt(Date lastLoginAttempt) {
this.lastLoginAttempt = lastLoginAttempt;
}
public Boolean getIsAccountLocked() {
return isAccountLocked;
}
public void setIsAccountLocked(Boolean isAccountLocked) {
this.isAccountLocked = isAccountLocked;
}
public Integer getLoginFailsNumber() {
return loginFailsNumber;
}
public void setLoginFailsNumber(Integer loginFailsNumber) {
this.loginFailsNumber = loginFailsNumber;
}
public Boolean getIsMfaEnabled() {
return isMfaEnabled;
}
public void setIsMfaEnabled(Boolean isMfaEnabled) {
this.isMfaEnabled = isMfaEnabled;
}
public Integer getUserTabID() {
return userTabID;
}
public void setUserTabID(Integer userTabID) {
this.userTabID = userTabID;
}
}
RegisterUser JSP page :
<form:form method="POST" action="${pageContext.request.contextPath}/register/registeruser.action" commandName ="user">
<table>
<tr>
<td><form:label path="loginName">UserName</form:label></td>
<td><form:input path="loginName" /></td>
<form:errors path="loginName" cssClass="error"/>
</tr>
<tr>
<td><form:label path="password">Password</form:label></td>
<td><form:input path="password" /></td>
<form:errors path="password" cssClass="error"/>
</tr>
<div id="question1" class="questionblock">
<tr>
<form:select path="userMfaMap.question1" >
<c:forEach items="${allMfaQuestions}" var="mfaQuestion">
<form:option value="${mfaQuestion.mfaQuestionId}">
<c:out value="${mfaQuestion.mfaQuestion}" />
</form:option>
</c:forEach>
</form:select>
</tr>
<tr>
<td><form:label path="userMfaMap.answer1">Answer:</form:label></td>
<td><form:input path="userMfaMap.answer1" /></td>
<form:errors path="userMfaMap.answer1" cssClass="error"/>
</tr>
</div>
<div id="question2" class="questionblock">
<tr>
<form:select path="userMfaMap.question2">
<c:forEach items="${allMfaQuestions}" var="mfaQuestion">
<form:option value="${mfaQuestion.mfaQuestionId}">
<c:out value="${mfaQuestion.mfaQuestion}" />
</form:option>
</c:forEach>
</form:select>
</tr>
<tr>
<td><form:label path="userMfaMap.answer2">Answer:</form:label></td>
<td><form:input path="userMfaMap.answer2" /></td>
<form:errors path="userMfaMap.answer2" cssClass="error"/>
</tr>
</div>
<div id="question3" class="questionblock">
<tr>
<form:select path="userMfaMap.question3">
<c:forEach items="${allMfaQuestions}" var="mfaQuestion">
<form:option value="${mfaQuestion.mfaQuestionId}">
<c:out value="${mfaQuestion.mfaQuestion}" />
</form:option>
</c:forEach>
</form:select>
</tr>
<tr>
<td><form:label path="userMfaMap.answer3">Answer:</form:label></td>
<td><form:input path="userMfaMap.answer3" /></td>
<form:errors path="userMfaMap.answer3" cssClass="error"/>
</tr>
</div>
<tr>
<td><input type="submit" name="submit" value="Submit"></td>
</tr>
</table>
</form:form>
Add code in the JSP form to bind the value of isMfaEnabled
<form:input path="isMfaEnabled" />
1st problem : i have a jsp in which there are two tabs ,for the second tab i have included the struts include tag. When i open the second tab and performs the action the second tab form values are not passing to the action.
2nd problem : in the select tag i have populate the list but it is coming as prepopulated means all the options are coming as selected="selected"
main jsp in which tabs are made
<!-- admin first tab starts here -->
<form action="saveRolesAndPermissions" method="post">
<table align="center">
<tr>
<td ><s:text name="FTID" ></s:text></td>
<td ><s:textfield id="FTID" name="ft_id">
</s:textfield></td>
<td><input type="button" value="validate" onclick="userPresent()"></td>
</tr>
</table>
<table>
<tr>
<td>First Name</td>
<td><input id="first_name" type="text" readonly onkeydown="return false"></td>
<td>Last Name</td>
<td><input id="last_name"
type="text" readonly onkeydown="return false"></td>
<td>Email-Id</td>
<td><input id="mail_id" type="text"
readonly onkeydown="return false"></td>
</tr>
</table>
<table align="center">
<tr>
<td><s:text name="ROLES"></s:text></td>
<td></td>
<td></td>
</tr>
<tr>
<td><s:text name="Available Roles"></s:text></td>
<td></td>
<td><s:text name="Assigned Roles"></s:text></td>
</tr>
<tr>
<td><s:select id="roles" name="availableRole"
multiple="true" list="availableRole"></s:select></td>
<td><input type="button" value=">" onclick="move_list_items('roles','assignedroles');"/><input
type="button" value="<" onclick="move_list_items('assignedroles','roles');"/></td>
<td><s:select id="assignedroles" name="assignedRole" multiple="true"
list="{}" >
</s:select></td>
</tr>
</table>
<br /> <br /> <br />
<table>
<tr>
<td><s:text name="Permissions"></s:text></td>
<td></td>
<td> </td>
</tr>
<tr>
<td><s:text
name="Available Permissions"></s:text></td>
<td></td>
<td><s:text name="Assigned Permissions"></s:text></td>
</tr>
<tr>
<td><s:select id="permissions" multiple="true"
name="availablePermission" list="availablePermission" headerValue=""></s:select></td>
<td><input
type="button" value=">" onclick="move_list_items('permissions','assignedpermissions');"/><br /> <input type="button"
value="<" onclick="move_list_items('assignedpermissions','permissions');" /></td>
<td><s:select id="assignedpermissions" multiple="true" name="assignedPermission"
list="{}" ></s:select></td>
</tr>
</table>
<br /> <br />
<table align="center" style="width: 25%;">
<tr>
<td><s:if test="hasActionMessages()">
<div class="welcome" style="list-style:none">
<s:actionmessage />
</div>
</s:if></td>
</tr>
</table>
<table>
<tr>
<td><s:submit
value="save"onclick="saveRole();return false;"></s:submit></td>
<td> <input type="button" name="close"
value="close" /></td>
</tr>
<tr>
<td></td>
<td></td>
</tr>
</table>
</form>
<!-- second tab for modify roles -->
<div id="content02" class="content" >
<s:include value="../asp/aspAdminModify.jsp"></s:include>
</div>
<!-- /second tab ends here -->
included jsp
<form action="grantedRolesAndPermissions" method="post">
<table>
<tr>
<td><s:text name="FTID" ></s:text></td>
<td><s:textfield id="modify_FTID" name="modifyftid">
</s:textfield></td>
<td><s:submit
value="search" onclick="search();return false;"></s:submit>
</td>
</tr>
</table>
Bean for the first tab
private String ft_id;
private ArrayList<String> availableRole;
private ArrayList<String> availablePermission;
private ArrayList<String> assignedRole;
private ArrayList<String> assignedPermission;
//getters and setters
Action for the first tab
public class ASPadmin extends ActionSupport implements ServletRequestAware, ModelDriven<ASPAdminBean>{
/**
*
*/
private static final long serialVersionUID = 1L;
private AdminASPService aspService = new AdminASPService();
private HttpServletRequest request = ServletActionContext.getRequest();
private HttpServletResponse response = ServletActionContext.getResponse();
public CMTUser cmtuser;
private ASPAdminBean aspAdminBean = new ASPAdminBean();
//getters and setters
public String populateRolesAndPermissions() throws Exception
{
/*aspAdminBean=new ASPAdminBean();*/
aspAdminBean.setAvailableRole(aspService.getRolesList());
aspAdminBean.setAvailablePermission(aspService.getPermissionsList());
return SUCCESS;
}
public String saveRolesAndPermissions() throws Exception
{
User user = CMTUser.getUser(request);
String login = user.getUserId();
String[] temp = login.split("\\.");
String abcfinal = temp[0].substring(0, 1).toUpperCase()
+ temp[0].substring(1);
String deffinal = temp[1].substring(0, 1).toUpperCase()
+ temp[1].substring(1);
String name = abcfinal + " " + deffinal;
System.out.println("name ==============>" + name);
String id = aspService.saveRolesPermissions(aspAdminBean,name);
System.out.println("id=======>"+id);
if("Y".equals(id)){
addActionMessage("Record Inserted Successfully");
populateRolesAndPermissions();
return SUCCESS;
}
else{
return ERROR;
}
}
#Override
public String execute() throws Exception {
String url = request.getRequestURL().toString();
String[] actionArray = url.split("/");
String event = null;
String forward = SUCCESS;
for (int i = 0; i < actionArray.length; i++) {
event = actionArray[i];
}
System.err.println(event);
try {
if (event.equals("aspAdmin.action")) {
populateRolesAndPermissions();
}
}catch (Exception e) {
e.printStackTrace();
}
return SUCCESS;
}
#Override
public void setServletRequest(HttpServletRequest req) {
this.request = req;
}
#Override
public ASPAdminBean getModel() {
// TODO Auto-generated method stub
return aspAdminBean;
}
}
bean for second tab
public class ASPAdminModifyBean {
private String modifyftid;
private String aspmodifyassignedRole;
private String aspmodifyassignedPermission;
private String createddate;
private String createdby;
private String updateddate;
private String updatedby;
private String username;
private ArrayList<String> modifyavailableRole;
private ArrayList<String> modifyavailablePermission;
private ArrayList<String> modifyassignedRole;
private ArrayList<String> modifyassignedPermission;
//getters and setters
action for the second tab
public class ASPadminModify extends ActionSupport implements ServletRequestAware, ModelDriven<ASPAdminModifyBean> {
private AdminASPService aspService = new AdminASPService();
private GetRolePermissionListInt[] roleVO;
private HttpServletRequest request = ServletActionContext.getRequest();
private HttpServletResponse response = ServletActionContext.getResponse();
private ASPAdminModifyBean modify = new ASPAdminModifyBean();
GetRolePermissionListInt role;
//getters and setters for the above
public String grantRolesPermissions(){
System.out.println("enter the grant roles and permissions");
String tab2="modify";
boolean id;
HttpServletRequest request=getRequest();
HttpSession session=request.getSession();
session.setAttribute("tabs",tab2 );
role=aspService.getGrantedRolesAndPermissions(modify);
System.out.println("assigned roles===================>"+role.getAssignedRoles());
modify.setAspmodifyassignedRole(role.getAssignedRoles());
modify.setAspmodifyassignedPermission(role.getAssignedPermissions());
modify.setCreatedby(role.getCreatedBy());
modify.setCreateddate(role.getCreatedDate());
modify.setUpdatedby(role.getUpdatedBy());
modify.setUpdateddate(role.getUpdatedDate());
modify.setUsername(role.getUserName());
modify.setModifyftid(role.getFtid());
System.out.println("assigned permissions==============>"+role.getAssignedPermissions());
System.out.println("updated by=================>"+role.getUpdatedBy());
System.out.println("update date=================>"+role.getUpdatedDate());
System.out.println("created by===================>"+role.getCreatedBy());
System.out.println("created date=====================>"+role.getCreatedDate());
System.out.println("ftid=============================>"+role.getFtid());
System.out.println("user name===========================>"+role.getUserName());
System.out.println("ftid=============>"+role.getFtid());
if(role!=null){
return SUCCESS;
}else{
return ERROR;
}
}
#Override
public void setServletRequest(HttpServletRequest arg0) {
// TODO Auto-generated method stub
}
#Override
public ASPAdminModifyBean getModel() {
// TODO Auto-generated method stub
return modify;
}
}
Well, the code is grown again :)
Start by :
changing your ArrayList declarations to List (in both beans, and regenerate getters and setters);
changing the way you get the Request, the Response and the Session, by using Struts2 Aware s interfaces (and their setters, with code inside)
Then if it still doesn't work, describe a little better what do you mean by "values are not passing to Action", and consider posting your interceptor stack config.
Hope that helps...