aspose file tools*
The moose likes Struts and the fly likes struts el  + html:text-el question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "struts el  + html:text-el question " Watch "struts el  + html:text-el question " New topic
Author

struts el + html:text-el question

Jason Rodrigues
Greenhorn

Joined: Oct 20, 2005
Posts: 21
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
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
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" />


Merrill
Consultant, Sima Solutions
Jason Rodrigues
Greenhorn

Joined: Oct 20, 2005
Posts: 21
ah!! thank you for your quick response . Appreciate your help . I see my mistake now
Thank you
Jason Rodrigues
Greenhorn

Joined: Oct 20, 2005
Posts: 21
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

Joined: Feb 15, 2005
Posts: 4864
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 ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: struts el + html:text-el question
 
Similar Threads
i am unable to figure out the problem with index
Expression Language not supported in compile time attribute items
JSTL conversion for struts 1.1 code
Problem Passing Parameter values to action
JSP Struts/JSTL Form problem