cancel
Showing results for 
Search instead for 
Did you mean: 

Access Problem to a Bean

Former Member
0 Kudos

Hello,

I have this piece of code which is using a bean:

bean = new ProfileBean();

IPortalComponentProfile userProfile = request.getComponentContext().getProfile();

Enumeration attr = userProfile.getPropertyAttributes(MYPROPERTY_KEY);

bean.setModelAttributes(this.createAttributesModel(attr, userProfile));

I receive this Exception:

Tag tableView attribute model: Cannot access bean property myProfileBean.modelAttributes in page context.

Can you please tell me what does this error means?

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi Roy,

do you have a useBean tag in your JSP?

It has to look similar to this example:

<jsp:useBean 
	id="MyBeanKey" 
	scope="session" 
	class="bean.MyBean" 
	/>

Kind regards

Francisco

Former Member
0 Kudos

Hi,

I think the right scope for accessing a bean stored in Profile would be "application"

Regards,

Christian

Former Member
0 Kudos

Hello,

I have this line at my jsp page:

<jsp:useBean id="myProfileBean" scope="application" class="bean.ProfileBean" />

So I beleive this answeres the last two suggestions...

Any other ideas?

Former Member
0 Kudos

Is the model you are trying to access, public?

Former Member
0 Kudos

Hi,

below you can find an example of code I used to access a model via a bean into a JSP and using it in a table view:

<jsp:useBean

id="compBean"

scope="application"

class="<bean class>"

/>

...

<hbj:tableView

id="myTableView"

width="100%"

model="<b>compBean.model</b>"

design="STANDARD"

headerVisible="false"

footerVisible="true"

fillUpEmptyRows="true"

selectionMode="NONE"

navigationMode="BYLINE"

visibleFirstRow="<%= compBean.getVisibleRow()%>"

visibleRowCount="5"

onNavigate="onNavigate">

>

</hbj:tableView>

an extract of bean class regarding the model:

public class ClassName implements Serializable {

private DefaultTableViewModel model;

...

/**

  • @return

*/

public DefaultTableViewModel getModel() {

return <b>model</b>;

}

/**

  • @param model

*/

public void setModel(DefaultTableViewModel model) {

this.model = model;

}

...

}

hope this help

Cheers

Roberto

Former Member
0 Kudos

To: Francisco Villar

The model I am trying to use is private but I have a public getModel method to return it. That's the whole idea of the Bean, to keep the Bean's instaces private and to let access only through public get methods. But, even if I am turning this instance to public I still receive the same error....

detlev_beutner
Active Contributor
0 Kudos

Hi Roy,

to shorten it: Please minimize your not working example as far as you can to reproduce the error (~ 20 line java, ~ 5 lines JSP; ~ 10 lines portalapp.xml) and submit it here. So we can maybe see the error at a glance without poking around a bit here and a bit there and even if not, catch the example and have it run.

Best regards

Detlev

Former Member
0 Kudos

A possible workaround is to call the java api in between the table view tags ( I remeber doing this but I am not sure what the root cause of the problem was)


<hbj:tableView
id="myTableView"
width="100%"

design="STANDARD"
headerVisible="false"
footerVisible="true"
fillUpEmptyRows="true"
selectionMode="NONE"
navigationMode="BYLINE"
visibleFirstRow="<%= compBean.getVisibleRow()%>"
visibleRowCount="5"
onNavigate="onNavigate">
>
<%
myTableView.setModel (compBean.getModel() ) ;
%>
</hbj:tableView>