How can I get the title of the referring page (item) from a modified version of feedback page in DSpace?

折月煮酒 提交于 2019-12-11 22:13:37

问题


How can I get the title of an item from a modified version of the feedback page just like in the "Recommend this item" in jspui? I'm hoping also to generate the resulting url of the page to be like http://example.com/feedback?handle=123456789/123. I've asked this from a comment in my previous post but I don't know how to use the HandleManager. I've tried many times using part of the code from itemRequestForm but I always get null pointer error.

    DSpaceObject dso = HandleUtil.obtainHandle(objectModel);
    if (!(dso instanceof Item)) {
        return;
    }
    Request request = ObjectModelHelper.getRequest(objectModel);
    boolean firstVisit=Boolean.valueOf(request.getParameter("firstVisit"));

    Item item = (Item) dso;

I also tried to looked in /ViewArtifacts/sitemap.xmap but right now it is beyond me to figure out what I am missing.


回答1:


You can get the complete patch of DS-2099 at:

https://github.com/arvoConsultores/DSpace/commit/3e971d70daaa4762a443c89fb7fa6f9e5b8e630d.patch

(TIP: you can add ".patch" to a commit at github to view the patch)

I Think its too long to post here.

Check SolicitarCorreccionForm to show the title and what you want using my other response to get the data from the handle and instead:

feedback.addPara(T_para1.parameterize(parameters.getParameter("handle","unknown")));

you should do:

String handle=parameters.getParameter("handle","unknown");

  // context=new Context(); // Context exist in a form:

  DSpaceOBject dso = HandleManager.resolveToObject(context,handle);

  if (dso instanceof Item){
       Item item=((Item)dso);
       DCValue[] titles= item.getMetadata("dc", "contributor", "author",null); 

       feedback.addPara(titles[0].value); // check for nulls or multiple values;
  }

to send the title to the mail class you should do:

feedback.addHidden("title").setValue(titles[0].value);

And at aspects/ViewArtifacts/sitemap.xmap you should set the parameter:

<map:transform type="SolicitarCorreccionForm">
<map:parameter name="title" value="{title}" />
...

Get at SendSolicitarCorreccionAction and send to email, to add the parameters to the mail like:

String title= request.getParameter("title");
email.addArgument(title);    // Titulo
...

You whould like to change the url from

<map:match pattern="solicitarCorreccion/**">

to what wou want.

P.D.- I forget to mention to add imports of SolicitarCorreccionForm:

import org.dspace.content.DCValue;
import org.dspace.content.DSpaceObject;
import org.dspace.content.Item;
import org.dspace.handle.HandleManager;

I hope this help.




回答2:


try

  String handle="1234/1234";

  context=new Context(); // Or reuse the Context:

  dso = HandleManager.resolveToObject(context,handle);

  if (dso instanceof Item){

       DCValue[] titles= dso.getMetadata("dc", "contributor", "author",null); 

       // use titles
  }


来源:https://stackoverflow.com/questions/26064830/how-can-i-get-the-title-of-the-referring-page-item-from-a-modified-version-of

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!