• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

how to make editable page non editable when i press save?????

 
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hello everyone

i am having one proble can anyone help me???

i have two button ADD and Submit.

when i press add the three afield will open...one is place_interview,date_interview and interview_schedule_userid

when i press save the data i am entering should save and it should not be able to be editable again......can anyone tell me how to do that.i will send the jsp file

when i press add this should be displayed

<%int cntLoop=0; %>
<table border=0 class="type1" >
<logic:equal name="User" property="notify_dept_interview_time" value="1" >
<logic:iterate id="selectionProcess" name="selectionProcess">
<%if (selF.getPlace_interview()!=null){%>
<tr>
<th class="type1opp"><bean:message key="sel.place_interview" /></th>
<td class="type1"><html:textarea name="selectionProcess" property="place_interview" indexed="true" onkeypress="textareaChars(this, 250)" cols="40" styleClass="textarea"/></td>
<th class="type1opp"><bean:message key="sel.date_interview" /></th>
<td class="type1"><html:text property="date_interview" name="selectionProcess"readonly="true" indexed="true" styleClass="input_medium"></html:text></td>
<th class="type1opp"><bean:message key="sel.userid" /></th>
<td class="type1"> <bean:write name="selectionProcess" property="interview_schedule_userid" /></td>
</tr>
<tr>
<td class="type1">)"> Candidates for Interview</td>
</tr>
<tr>

And when i press save this should be displayed

<%}else{%>
<th class="type1opp"><bean:message key="sel.place_interview" /></th>
<td class="type1"><bean:write name="selectionProcess" property="place_interview"/></td>
<th class="type1opp"><bean:message key="sel.date_interview" /></th>
<td class="type1"><bean:write name="selectionProcess" property="date_interview"/></td>
<th class="type1opp"><bean:message key="sel.userid" /></th>
<td class="type1"> <bean:write name="selectionProcess" property="interview_schedule_userid" /></td>
</tr>
<tr>
<td class="type1"> Candidates for Interview</td>
</tr>
<%}%>
</logic:iterate>
</logic:equal>

i will also post my action class if needed...can anyone help me out

thanks
sanju
 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Could you disable HTML please? I find that a little hard to read.

If you're forwarding to a different page on the save just display the values. If you're forwarding to the form page when you hit save then use boolean logic and either display the form or the values.
 
sanju sreedharan
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hello david can you forward me your email id i will send the coding through mail

sanaj
 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Click the "disable HTML in this message" checkbox. Put the code inside code tags.
 
sanju sreedharan
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
my jsp page
---------------
<logic:equal name="User" property="notify_dept_interview_time" value="1" >

<logic:iterate id="selectionProcess" name="selectionProcess">


<%if (selF.getPlace_interview()==null){%>
<tr>
<th align=left class="type1opp"><bean:message key="sel.place_interview" /></th>
<td width="22%" class="type1"><html:textarea name="selectionProcess" property="place_interview" indexed="true" onkeypress="textareaChars(this, 250)" cols="40" styleClass="textarea"/></td>
<th align=left class="type1opp"><bean:message key="sel.date_interview" /></th>
<td width="22%" class="type1"><html:text property="date_interview" name="selectionProcess"readonly="true" indexed="true" styleClass="input_medium"></html:text><img src="../images/cal.gif" onclick="return showCalendar('selectionProcess[<%=cntLoop++%>].date_interview','%d/%m/%Y %H:%M', '12', true);" style="cursor:hand;" width="16" height="16"/></td>
<th align=left class="type1opp"><bean:message key="sel.userid" /></th>
<td width="22%" class="type1"> <bean:write name="selectionProcess" property="interview_schedule_userid" /></td>
</tr>
<tr>
<td colspan=3 align=middle class="type1"><a href="javascript:void()" onclick="javascript:return resumesearch(<bean:write name="selectionProcess" property="selection_prid" />)"> Candidates for Interview</a></td>
</tr>
<tr>

<%}else{%>
<th align=left class="type1opp"><bean:message key="sel.place_interview" /></th>
<td width="22%" class="type1"><bean:write name="selectionProcess" property="place_interview"/></td>
<th align=left class="type1opp"><bean:message key="sel.date_interview" /></th>
<td width="22%" class="type1"><bean:write name="selectionProcess" property="date_interview"/></td>
<th align=left class="type1opp"><bean:message key="sel.userid" /></th>
<td width="22%" class="type1"> <bean:write name="selectionProcess" property="interview_schedule_userid" /></td>
</tr>
<tr>
<td colspan=3 align=middle class="type1"><a href="javascript:void()" onclick="javascript:return resumesearch()"> Candidates for Interview</a></td>
</tr>

<%}%>
</logic:iterate>
</logic:equal>

<jsp:include page="bottom5.jsp" flush="true" />
<jsp:include page="bottom3.jsp" flush="true" />

my action class
______________




// used to add dynamically

if(submit!=null&&submit.equalsIgnoreCase("Add"))
{
Dml dml=new Dml();
selectionProcess=new ArrayList();
for(int i=0;;i++)
{
String place_interview="selectionProcess["+i+"].place_interview";
String date_interview="selectionProcess["+i+"].date_interview";

if(request.getParameter(place_interview)==null)break;

SelectionDetails details=new SelectionDetails();
details.setVacancy_refno(selForm.getVacancy_refno());
details.setRecycle_no(selForm.getRecycle_no());
details.setPlace_interview(request.getParameter(place_interview));
details.setDate_interview(request.getParameter(date_interview));
selectionProcess.add(details);
}

SelectionDetails sd=new SelectionDetails();
sd.setPlace_interview("");
sd.setDate_interview("");
selectionProcess.add(sd);
dml.populateSelectionForm(selForm,selForm.getVacancy_refno(),selForm.getRecycle_no());

divs=dmlu.getDivision(selForm.getDivision());
depts=dmlu.getDepartment(selForm.getDept(),selForm.getDivision());
sections=dmlu.getSection(selForm.getDept(), selForm.getDivision(), selForm.getSection());
langs=dmlu.getLanguage_only_one(selForm.getLanguage());
grades=dmlu.getGrade_onlyone(selForm.getGrade());
ageranges=dmlu.getAgerange(selForm.getAge_range());
nationality=dmlu.getNationality(Integer.parseInt(selForm.getNation()));
}

// for saving

public SelectionForm approve(SelectionForm selForm,HttpServletRequest request,User user)
{
try
{
Dml dml=new Dml();
if(selForm.getInterview_schedule_userid()==null||selForm.getInterview_schedule_userid().equals(""))
{
selectionProcess=new ArrayList();
for(int i=0;;i++)
{
String place_interview="selectionProcess["+i+"].place_interview";
String date_interview="selectionProcess["+i+"].date_interview";

if(request.getParameter(place_interview)==null)break;

SelectionDetails details=new SelectionDetails();
details.setVacancy_refno(selForm.getVacancy_refno());
System.out.println("VACANCY_REFNO=================="+selForm.getVacancy_refno());
details.setRecycle_no(selForm.getRecycle_no());
System.out.println("RECYCLE_nO=================="+selForm.getRecycle_no());
details.setPlace_interview(request.getParameter(place_interview));
System.out.println("PLACE_INTERVIEW=================="+selForm.getPlace_interview());
details.setDate_interview(request.getParameter(date_interview));
System.out.println("DATE_INTERVIEW=================="+selForm.getDate_interview());
details.setInterview_schedule_userid(user.getUserid());
selectionProcess.add(details);
selForm=dml.selectionList(details.getVacancy_refno(),details.getRecycle_no(),details.getPlace_interview(),details.getDate_interview(),details.getInterview_schedule_userid(),details.getSelection_prid(),selForm);
}
}
______________________________________________________________________________



function to store in the database

__________________________________________________________________________________________

public SelectionForm selectionList(String vacancy_refno,String recycle_no,String place_interview,
String date_interview, String interview_schedule_userid,String selection_prid,SelectionForm selForm)
{
Connection dbConnection = null;
PreparedStatement psmt1 = null;
ResultSet rs1=null;
try
{
OracleServerAccess dbAccess = new OracleServerAccess();
dbConnection = dbAccess.openConnection();
String sq1="insert into ts_selection_details(VACANCY_REFNO,RECYCLE_NO,PLACE_INTERVIEW,DATE_INTERVIEW,SELECTION_PRID,DATE_INTERVIEW_INPUT_DATE,"+
"INTERVIEW_SCHEDULE_USERID) values ('"+vacancy_refno+"','"+recycle_no+"'," +
"'"+place_interview+"'," +
"to_date('"+date_interview+"','dd/mm/yyyy HH24:MI:SS')," +
"SEQ_RECID.NEXTVAL,to_date(sysdate,'dd/mm/yyyy HH24:MI:SS'),"+
"'"+interview_schedule_userid+"')";
logger.info(sq1);
psmt1 =dbConnection.prepareStatement(sq1);
rs1=psmt1.executeQuery();
if(rs1.next())
sq1="select " +
" DATE_INTERVIEW_INPUT_DATE,PLACE_INTERVIEW,DATE_INTERVIEW,interview_schedule_userid from ts_selection_details where " +
" vacancy_refno='"+selForm.getVacancy_refno()+"' and recycle_no='"+selForm.getRecycle_no()+"'";
logger.info(sq1);
psmt1=dbConnection.prepareCall(sq1);
psmt1.executeUpdate();
}
catch(Exception e)
{
logger.info(e.getMessage());
e.printStackTrace();
}
finally
{
try
{
if(rs1!=null)rs1.close();
if(psmt1!=null)psmt1.close();
if(dbConnection!=null)dbConnection.close();
}
catch(Exception e){}
}
return selForm;
}


 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Are you wanting to re-load the page, or change it in-place?

If you're doing a full submission and reloading the page just set a flag in, say, request scope, and check for it in the code.

By the way, creating a string SQL statement using raw form values is a very, ***very*** bad idea.
 
sanju sreedharan
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hello david

thank you for the reply..can you please tell me a best way to store in a database..whether there is any drawbacks in the way i did

thanks
sanaj
 
Ranch Hand
Posts: 249
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Even if it is right in the same page, you can check for value existence, and invoke javascript to disable to field from further editing.

And for database storing, if you feel the DAO pattern is not good enough, and ORM is too much, still you can have some POJOs dedicated for DB
stuff, to ascertain that the values are in right format [and type checking] and finally create the SQL wherein modification of the same can be done with minimum of fuss.

Dawn
 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Use prepared statements or clean the string values before creating an SQL string out of them.

I had thought SQL injection is a pretty well-known issue, but it's off-topic for this forum.
 
sanju sreedharan
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hello david

I had thought SQL injection is a pretty well-known issue, but it's off-topic for this forum. ???

david i didnt understand what you mean by this..can you please tell me clearly

thanks
sanju
 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
http://tinyurl.com/9wouw9
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic