How to display in inline mode, only an specific field from a class

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

How to display in inline mode, only an specific field from a class

Heitor Mayer
I would like to know how to display only an specific field from a class in inline mode, obviously using the code in the class sheet related to that class.
 
I would like to show only one field in inline mode because I need that embeddeb html editor that appears only in inline mode for text fields. The other fields can be showed in normal edit mode. 
 
Thank you so much 


      Veja quais são os assuntos do momento no Yahoo! +Buscados
http://br.maisbuscados.yahoo.com
_______________________________________________
users mailing list
[hidden email]
http://lists.xwiki.org/mailman/listinfo/users
Reply | Threaded
Open this post in threaded view
|

Re: How to display in inline mode, only an specific field from a class

jerem
If I understood well, I think you should be able to do it by updating the characteristics of your text fields in your class : you can choose the "Editor" to use (Text, PureText or WysiWyg). Choose wysiwyg to have the html editor, and text or puretext for standard text field.
To display a field have a look to the javadoc (Document.display() methods)

I.E. :
public java.lang.String display(java.lang.String fieldname,
                                java.lang.String mode,
                                Object obj)

Here mode can be 'edit' or 'view' ... (I don't know all possible values).
Reply | Threaded
Open this post in threaded view
|

Re: How to display in inline mode, only an specific field from a class

Heitor Mayer
In reply to this post by Heitor Mayer
First of all, thank you for your answer.
I tried to change the type of Editor to WUSIWYG, but even after the change, the field appears like this one :
 
(∗) TXProblema:
 

I have been using public java.lang.String display(java.lang.String fieldname,
                                java.lang.String mode) with mode = "edit" in order to display the field
 
I already tried mode = "inline", but nothing happens
 
My problem is just that I need the embedded html editor.
When I call the page in inline mode, it shows every field in inline mode along with many different buttons, what I do not want, because I want to have only one button(my own button) to save the page content, so this is the reason I want only one field(of the type Text Area) in inline mode.
 
Thank you in advance. 
 

--- Em qua, 3/6/09, jerem <[hidden email]> escreveu:


De: jerem <[hidden email]>
Assunto: Re: [xwiki-users] How to display in inline mode, only an specific field from a class
Para: [hidden email]
Data: Quarta-feira, 3 de Junho de 2009, 11:58



If I understood well, I think you should be able to do it by updating the
characteristics of your text fields in your class : you can choose the
"Editor" to use (Text, PureText or WysiWyg). Choose wysiwyg to have the html
editor, and text or puretext for standard text field.
To display a field have a look to the javadoc (Document.display() methods)

I.E. :
public java.lang.String display(java.lang.String fieldname,
                                java.lang.String mode,
                                Object obj)

Here mode can be 'edit' or 'view' ... (I don't know all possible values).
--
View this message in context: http://n2.nabble.com/How-to-display-in-inline-mode%2C-only-an-specific-field-from-a-class-tp3018244p3018773.html
Sent from the XWiki- Users mailing list archive at Nabble.com.

_______________________________________________
users mailing list
[hidden email]
http://lists.xwiki.org/mailman/listinfo/users



      Veja quais são os assuntos do momento no Yahoo! +Buscados
http://br.maisbuscados.yahoo.com
_______________________________________________
users mailing list
[hidden email]
http://lists.xwiki.org/mailman/listinfo/users
Reply | Threaded
Open this post in threaded view
|

Re: How to display in inline mode, only an specific field from a class

Jean Couteau
Heitor Mayer a écrit :

> First of all, thank you for your answer.
> I tried to change the type of Editor to WUSIWYG, but even after the change, the field appears like this one :
>  
> (∗) TXProblema:
>  
>
> I have been using public java.lang.String display(java.lang.String fieldname,
>                                 java.lang.String mode) with mode = "edit" in order to display the field
>  
> I already tried mode = "inline", but nothing happens
>  
> My problem is just that I need the embedded html editor.
> When I call the page in inline mode, it shows every field in inline mode along with many different buttons, what I do not want, because I want to have only one button(my own button) to save the page content, so this is the reason I want only one field(of the type Text Area) in inline mode.
>  
> Thank you in advance.
>  
Hi Heitor

Here is a piece of code that might help you : it is an extract from one
of my class sheets, where I customized the inline edit :

#if($context.action=="inline")
  #set($class = $doc.getObject("XWiki.USClass").xWikiClass)
  #set($hasProps = false)
  #foreach($prop in $class.properties)
    #if($velocityCount == 1)
      #set($hasProps = true)
      <dl>
    #end
##Here, I choose not to display some of the fields.
    #if
((${prop.prettyName}!="id")&&(${prop.prettyName}!="name")&&(${prop.prettyName}!="actor"))
      <dt> ${prop.prettyName} </dt>
      <dd>$doc.display($prop.getName())</dd>
    #end
    #if (${prop.prettyName}=="id")
      ##<dt> ${prop.prettyName} (DO NOT MODIFY)</dt>
      ##<dd>$doc.display($prop.getName())</dd>
    #end
  #end
  #if($hasProps)
    </dl>
  #end
##From here, I display some external fields in view mode (not for edition)
  $context.setDisplayMode("view")
  <table>
  <tr><th>Release</th><th>Sprint</th></tr>
  <tr>
 <td>#set($allReleaseLinks=$xwiki.getDocument("Project.ReleaseLinks").getObjects("XWiki.ReleaseUSLinkClass"))
          #foreach($link in $allReleaseLinks)
            #if($link.get("usId")==${doc.display("id")})
              #set($url="Project."+$link.get("releaseId"))
              #set($releasedoc=$xwiki.getDocument($url))
              #set($release=$releasedoc.getObject("ReleaseClass"))
              [$release.get("name")>$url]    <a
href="../../view/Project/planner?backlog=${doc.display("id").substring(0,1)}&usId=${doc.display("id")}&releaseId=${link.releaseId}">X</a>
\\
            #end
          #end
          <a
href="../../view/Project/ReleaseLinks?backlog=${doc.display("id").substring(0,1)}&usId=${doc.display("id")}">Add</a></td>        

   
<td>#set($allSprintLinks=$xwiki.getDocument("Project.SprintLinks").getObjects("XWiki.SprintUSLinkClass"))
          #foreach($link in $allSprintLinks)
            #if($link.get("usId")==${doc.display("id")})
              #set($url="Project."+$link.get("sprintId"))
              #set($sprintdoc=$xwiki.getDocument($url))
              #set($sprint=$sprintdoc.getObject("SprintClass"))
              [$sprint.get("name")>$url]   <a
href="../../view/Project/planner?backlog=${doc.display("id").substring(0,1)}&usId=${doc.display("id")}&sprintId=${link.sprintId}">X</a>\\
            #end
          #end
          <a
href="../../view/Project/SprintLinks?backlog=${doc.display("id").substring(0,1)}&usId=${doc.display("id")}">Add</a></td>
  </tr>
  </table>
#end


Note that you might need to put a $context.setDisplayMode("inline") at
the end (it's the end of my page so I did not put it)

Like that you can use the XWiki buttons to save the changes (it's inline
mode after all).

I think that if you want to do that in another page, you might want to
switch between inline mode and view mode using the
$context.setDisplayMode() to display your field.

I hope that might help you.

Best regards

Jean

--
----
Jean Couteau
Code Lutin - http://www.codelutin.com
44 Bd des Pas Enchantés - 44230 St-Sébastien/Loire
Tél : 02 40 50 29 28 - Fax : 09 59 92 29 28

_______________________________________________
users mailing list
[hidden email]
http://lists.xwiki.org/mailman/listinfo/users