• 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:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Dynamic Textboxes.

 
Ranch Hand
Posts: 213
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Merrill / Other Ranchers around,

This time i am in a confusion as to how to generate Dynamic Textboxes based on the values coming from the database.

For instance , There are four fields called jobType,ItemCode,Quantity and Rate which would be coming from the Database. Based on the size of the Collection i.e ArrayList , on the JSP corresponding number of Textboxes should get generated automatically with all the details populated.

Can you shred some light on how this can be achieved ?

Thanks in Advance.

Yogendra N Joshi
 
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You will need to used indexed properties for this. Please carefully read the following two articles:

http://struts.apache.org/1.2.9/faqs/indexedprops.html
http://wiki.apache.org/struts/StrutsCatalogLazyList

You can also search this forum for the topic "indexed properties" and find a lot of discussion regarding this topic.

Let us know if you have specific problems implementing these techniques for your situation.
 
Yogendra Joshi
Ranch Hand
Posts: 213
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Merrill ,

Thanks for the reply. Let me check out the links and try out. If there is a problem implementing it, Would get back to you.

Thanks again.

Yogendra N Joshi.
 
Yogendra Joshi
Ranch Hand
Posts: 213
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Merill ,

According to what you helped , I tried doing it but facing a problem called "No Collection Found" and sometimes i get "Cannot create iterator for..".
These are my all files , Appreciate if you can help me out.

JSP File :

-------------------------------------------

<html:form action="/login">
<logic:iterate id="yogendra" name="loginform" property="txtList">
<html:text property="name" name="yogendra" size="30" indexed="true"/>
</logic:iterate>
<html:submit>Submit</html:submit>
</html:form>

--------------------------------------------

Action Class :

---------------------------------------------



ActionForm :

-------------------------------------------



struts-config.xml file :

-------------------------------------------

<!-- Start of Struts Config File -->
<struts-config>

<!-- Standard Form Beans for TestStruts Application -->

<form-beans>
<form-bean name="loginform" type="orgy.yogendra.LoginForm"/>
</form-beans>

<!-- Standard Action Mappings for thew TestStruts Application -->

<action-mappings>
<action path="/login"
name="loginform"
validate="false"
type="LoginAction"
scope="request">
<forward name="page" path="/loginForm.jsp"/>
</action>
</action-mappings>

<!-- End of Struts Config File -->

</struts-config>

-------------------------------------------

for the Action , ActionForm and JSP files , I have included only those relavent parts , I have omitted imports and taglib declarations in this post. But they do exist in my all files

Hope , I will again be helped by you as always

Thanks in Advance.
Yogendra.
 
Ranch Hand
Posts: 948
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Action Class: Looks pretty good though you can probably remove the call request.setAttribute..and in any case you would not want to call this every time through the loop.

Action Form: For indexed properties you need methods that take an index as a parameter. Like the following. It has been a little while since I have written index properties for simple types like String, so this might not be exactly right. The method getTxtItem might not be needed.


JSP File: You then need to hook your JSP code up to use the txtItem indexed methods in your form. The following might be correct. Again, I am not sure of the syntax for simple types like Strings.


For the longest time I did not understand how to get indexed properties working (mostly because I did not know that the id attribute of the logic:iterate tag should match up with the property name in the form) so I would hand roll the index code like this (in which case the method getTxtItem is needed in the form):


- Brent
 
Yogendra Joshi
Ranch Hand
Posts: 213
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Brent ,

Thanks for the help.. Not being successful..

Can you please elaborate more. Also i would wish Merrill to help in this case...

Thanks in Advance.
Yogendra Joshi.
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You will need to be more specific than "not being successful". Give us the specific error message and tell us at what point it occurs (When the page submits? when it is displayed for the first time?).

I assume you modified your code according to Brent's suggestions. Can you show us the modified code?
 
Brent Sterling
Ranch Hand
Posts: 948
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I put together a simple example of a page that had a list of phone numbers. I tried a couple things, but I could not get the html:text tag working with indexed="true". I was able to get it working using some JavaScript to build the indexes. Here is my code:


- Brent
 
Ranch Hand
Posts: 85
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This can be easily done using the display tag...

See the following format for help

here...requestURI="/disputeOrValidate.do?method=DISPUTEORVALIDATE"
is the action to be called for displayin the values and
name="sessionScope.ChargeAnalysisListVO.chargeAnalysisList"
is the Object and its arraylist in session or request scope

<display:table requestURI="/disputeOrValidate.do?method=DISPUTEORVALIDATE"
requestURIcontext="false"
name="sessionScope.ChargeAnalysisListVO.chargeAnalysisList"
pagesize="5" class="data sortable" excludedParams="method" id="row"
style="width: 725px;" size="20">

<display:column property="strProductDescription" titleKey="title.Description" />

<display:column property="strCircuitId" titleKey="title.CircuitId" />

<display:column property="dateChargeFromDate" titleKey="title.ChargeFrom" />

<display:column property="dateChargeToDate" titleKey="title.ChargeTo" />

<display:column property="douOneOffChargeOut"
titleKey="title.One-OffCharge£" />

<display:column property="douAnnualCharge"
titleKey="title.AnnualCharge£" />

<display:column property="douTotalChargeOut" titleKey="title.Charge£" />
<display:column titleKey="title.Ticktodispute">
<c:if
test='${row.strBillingStatus eq "Ready for Customer Validation"}'>
<html-el:checkbox name="disputeForm"
property="intDisputeOrValidateCheck"
value="${row.intUnbilledChargeId}" tabindex="9" />

</c:if>
<c:if
test='${row.strBillingStatus ne "Ready for Customer Validation"}'>

<c ut value="${row.strBillingStatus}" />

</c:if>


</display:column>

</display:table>
 
reply
    Bookmark Topic Watch Topic
  • New Topic