• 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

struts el + html:text-el question

 
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi
was wondering if any of guys had encounter an error like this .
I am currently working with struts version 1.2.4 . I have struts.jar and struts-el.jar in web-inf/lib.

loanModel is the action form that is placed in the session. When i loop through and when i use <c ut value="${borrower.lastName}"/> to display the name it is fine but if i use <html:text-el property ="${borrower.lastName}"/>, i run into trouble it gives me the error



This is what i have in my page


if i dont use jstl i can do this and it works fine

<logic:iterate id="borrower" property="workFlowLoanDetail.borrowerList" name="model" indexId="indBorrower">
<logic:iterate id="employment" property='%="workFlowLoanDetail.borrowerList["+indBorrower+"].employmentList"%' name="model" indexId="indEmp">
<html:text property='%="workFlowLoanDetail.borrowerList["+indBorrower+"].employmentList["+indEmp+"].employerName"%' />

Any suggestions ?
Thank you
 
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Your usage of the <html-el:text> tag is incorrect. The only difference between an <html-el:text> tag and a <html:text> tag is that with the former you can use EL in a runtime expression, whereas with the latter you must use a scriptlet.

By specifying property="${borrower.lastName}", you're telling struts to evaluate $borrower.lastName} and make that the name of the property, which I'm sure is not what you want.

You need to handle the property value for the <html-el:text> the same way you handled it using the <html:text> tag except that you'll use EL expressions to get the index values rather than scriptlets. Something like this:

<html-el:text property="workFlowLoanDetail.borrowerList[${status.index}].lastName" />
 
Jason Rodrigues
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
ah!! thank you for your quick response . Appreciate your help . I see my mistake now
Thank you
 
Jason Rodrigues
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Merrill
I was thinking about what you said
I have defined a bean and named it "model"
<bean efine id="model" type="com.gmacb.blt.whlstruts.audecision.LoanModel" name="loanModel" scope="session"/>

so when i use basic struts .I tie the workFlowLoanDetailt attribute via the name "model" to the form bean in the session
<logic:iterate id="borrower" property="workFlowLoanDetail.borrowerList" name="model" indexId="indBorrower">


<html:text property='%="workFlowLoanDetail.borrowerList["+indBorrower+"].employmentList["+indEmp+"].employerName"%' />

but if i use jstl how do i access the form bean in the session,I need to do something like ${loanModel}

how will this know it has to access the workFlowLoanDetail attribute of the loanModel stored in the session ?

<html-el:text property="workFlowLoanDetail.borrowerList[${status.index}].lastName" />

Thankx for your help I tried
<html-el:text property="${loanModel.workFlowLoanDetail.borrowerList[{status.index].lastName}" /> , but that again is wrong as you mentioned

Any suggestions ?
thankx
-reeve
 
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
In either the <html:text> or <html-el:text> tags, when you specify a property attribute without a name attribute, the assumption is that the property you're specifying belongs to ActionForm bean that is assigned to the action used by this form. You don't need a <bean efine> for it, because it's already defined when you specify <html:form action="/myAction">. The ActionForm bean you defined as belonging to /myAction in your struts-config.xml file is automatically defined for use by all <html:xxx> and <html-el:xxx> tags.

Indexed properties work exactly the same way for either tag. Here is a link to refresh your memory on how indexed properties work.

When you're dealing with indexed properties, remember that the property name used in a <html:xx> tag is always realtive to the action form, not to the current iteration of either a <logic:iterate> or a <c:forEach> tag. Only the index is relative to the <c:forEach> tag.

So, if the Actionform bean for the current action has a property named "workFlowLoanDetail", then the tag would be exactly the one I showed you in my last post:


Another difference between the <html:xx> and the <html-el:xxx> tags is that with <html:xxx> tags, you can use scriptlets to substitue for an attribute, but the rule is "all or nothing", meaning that the whole attribute must be a scriptlet, or no part of it can be a scriptlet. With <html-el:xxx> tags, this rule does not apply. You can intermix regular text with EL expressions.
[ May 02, 2006: Message edited by: Merrill Higginson ]
 
reply
    Bookmark Topic Watch Topic
  • New Topic