Forum Discussion

bryanpollack's avatar
11 years ago
Solved

Permission error?

For some reason, when I'm not signed in I can't seem to view my custom component. I get "This widget could not be displayed." I think I've tracked it down to the following lines:

 

<#attempt>
<#assign pageNum = env.context.component.getParameter('pageNum') />
<#recover>
<#assign pageNum = 1 />
</#attempt>

 

If I remove the getParameter call, it seems to work fine. I've tried all of the different permissions but it still didn't seem to work. Why isn't this working on non-admin accounts? BTW, all my REST calls use restadmin, so that shouldn't be the issue either.

  • Hi Bryan,

     

    Without seeing more of the code in context, it's difficult to say exactly what might be causing the error.

     

    One thing I would suggest is setting a default value on the assign, using the default value operator in FreeMarker (http://freemarker.org/docs/dgui_template_exp.html#dgui_template_exp_missing_default). There could be a case where perhaps you're not getting back the value you'd expect from env.context.component.getParameter('pageNum') but if an exception isn't thrown then it wouldn't make it into the recover block and get assigned there. So instead, you might want to try something like this:

     

    <#attempt>
    <#assign pageNum = env.context.component.getParameter('pageNum')!1 />
    <#recover>
    <#assign pageNum = 1 />
    </#attempt>

     I hope this helps!

     

3 Replies

  • HaidongG's avatar
    HaidongG
    Lithium Alumni (Retired)
    11 years ago

    Hi Bryan,

     

    sorry, i am not answering your question, :smileytongue:

     

    I just hope that it is aware that "restadmin" will ignore all security settings and perform the REST call as the admin. for example, message listing will return results even the user has no access to (hidden boards, moderator boards and etc), update certain system or other users' setting even he is not administrator. In most of the time, "rest" should be sufficient in your custom component.

  • AdamN's avatar
    AdamN
    Khoros Oracle
    11 years ago

    Hi Bryan,

     

    Without seeing more of the code in context, it's difficult to say exactly what might be causing the error.

     

    One thing I would suggest is setting a default value on the assign, using the default value operator in FreeMarker (http://freemarker.org/docs/dgui_template_exp.html#dgui_template_exp_missing_default). There could be a case where perhaps you're not getting back the value you'd expect from env.context.component.getParameter('pageNum') but if an exception isn't thrown then it wouldn't make it into the recover block and get assigned there. So instead, you might want to try something like this:

     

    <#attempt>
    <#assign pageNum = env.context.component.getParameter('pageNum')!1 />
    <#recover>
    <#assign pageNum = 1 />
    </#attempt>

     I hope this helps!