| Register | FAQ | Calendar | Search | Today's Posts | Mark Forums Read |
|
#1
| |||
| |||
| Hi Does any done this task on Portal 6.0.1.0 i have tried but portlet displaying on seperate Window. i have give anchor tag as refresh url and also tried using button with help of ajax javascript it's working fine but only fragment updated not entire portlet. so give me suggestions THANKS IN ADVANCE Rajasekhar |
|
#2
| |||
| |||
| yes I have done it, and it is as designed to only update the fragment, the goal is that your ajax requests gets the request back and then updates the innerhtml how does your code look? it would also better to use a button with an onclick IBM Certified System Administrator -- WebSphere Portal V6.0, V5.1, V5.0 IBM Certified Solution Developer -- WebSphere Portal V5.1, v6.0 The postings on this site are my own and do not necessarily represent the positions, strategies, or opinions of IBM |
|
#3
| |||
| |||
| HI JIM, i have tried with onclick event with SinglePortletRefresh url but it's not getting this my code snippet so clarify my doubt and in doView Mode i wrote Button tag as renderResponse so do the needfull. import java.io.*; import java.util.*; import javax.naming.Context; import javax.naming.InitialContext; import javax.naming.NamingException; import javax.portlet.*; import com.ibm.portal.ModelException; import com.ibm.portal.portlet.service.PortletServiceHome; import com.ibm.portal.portlet.service.model.PortletModelP rovider; import com.ibm.portal.portletmodel.PortletWindow; import com.ibm.portal.state.EngineURL; import com.ibm.portal.state.PortletStateManager; import com.ibm.portal.state.StateHolderController; import com.ibm.portal.state.URLFactory; import com.ibm.portal.state.accessors.portlet.PortletAcce ssorController; import com.ibm.portal.state.accessors.portlet.PortletTarg etAccessorController; import com.ibm.portal.state.accessors.selection.Selection AccessorController; import com.ibm.portal.state.accessors.selection.Selection AccessorFactory; import com.ibm.portal.state.exceptions.StateException; import com.ibm.portal.state.service.PortletStateManagerSe rvice; /** * A sample portlet based on GenericPortlet */ public class SinglePortletRefresh extends GenericPortlet { public static final String JSP_FOLDER = "/_SinglePortletRefresh/jsp/"; // JSP folder name public static final String VIEW_JSP = "SinglePortletRefreshView"; // JSP file name to be rendered on the view mode public static final String EDIT_JSP = "SinglePortletRefreshEdit"; // JSP file name to be rendered on the edit mode public static final String HELP_JSP = "SinglePortletRefreshHelp"; // JSP file name to be rendered on the help mode public static final String SESSION_BEAN = "SinglePortletRefreshSessionBean"; // Bean name for the portlet session public static final String FORM_SUBMIT = "SinglePortletRefreshFormSubmit"; // Action name for submit form public static final String FORM_TEXT = "SinglePortletRefreshFormText"; // Parameter name for the text input public static final String EDIT_SUBMIT = "SinglePortletRefreshEditSubmit"; // Action name for submit form public static final String EDIT_TEXT = "SinglePortletRefreshEditText"; // Parameter name for the text input public static final String EDIT_KEY = ".SinglePortletRefreshEditKey"; // Key for the portlet preferences private static final String JNDI_STATE_SERVICE="portletservice/com.ibm.portal.state.service.PortletStateManagerSe rvice"; private static final String JNDI_MODAL_PROVIDER="portletservice/com.ibm.portal.portlet.service.model.PortletModelP rovider"; protected PortletStateManagerService stateService; protected PortletModelProvider modelProvider; /** * @see javax.portlet.Portlet#init() */ public void init() throws PortletException{ super.init(); try{ final Context context= new InitialContext(); PortletServiceHome psh=(PortletServiceHome)context.lookup(JNDI_STATE_ SERVICE); stateService = (PortletStateManagerService)psh.getPortletService( PortletStateManagerService.class); psh=(PortletServiceHome)context.lookup(JNDI_MODAL_ PROVIDER); modelProvider = (PortletModelProvider)psh.getPortletService(Portle tModelProvider.class); }catch(NamingException ne){ System.err.println(ne); } } /** * Serve up the view mode. * * @see javax.portlet.GenericPortlet#doView(javax.portlet. RenderRequest, javax.portlet.RenderResponse) */ public void doView(RenderRequest request, RenderResponse response) throws PortletException, IOException { // Set the MIME type for the render response response.setContentType(request.getResponseContent Type()); final PrintWriter writer = response.getWriter(); try{ System.err.println("VIEW"); //Get the request specifict Portal state manager final PortletStateManager stateManager = stateService.getPortletStateManager(request,respon se); final PortletWindow portletWindow = modelProvider.getCurrentPortletWindow(request); final URLFactory factory = stateManager.getURLFactory(); final EngineURL engineURL=factory.newURL(null); Map renderparams = new HashMap(); //renderparams.put("name","rajasekhar"); //final EngineURL engineURL = createActionURL(stateManager,portletWindow,renderp arams); final StateHolderController state = engineURL.getState(); setSelectionMapping(stateManager,portletWindow,sta te); setState(stateManager, portletWindow, state,null,null, renderparams); //writer.print(" Single Portlet Refresh link "); // dispose the objects that are no longer needed writer.print(" "); factory.dispose(); stateManager.dispose(); }catch(StateException se){ }catch(ModelException me){ } // Check if portlet session exists SinglePortletRefreshSessionBean sessionBean = getSessionBean(request); if( sessionBean==null ) { response.getWriter().println(" NO PORTLET SESSION YET "); return; } // Invoke the JSP to render PortletRequestDispatcher rd = getPortletContext().getRequestDispatcher(getJspFil ePath(request, VIEW_JSP)); rd.include(request,response); } /** * Helper method which maps the currently selected page to the given portlet window. * Typically this method will operate on a URL-specific state holder. */ protected void setSelectionMapping(final PortletStateManager stateManager, final PortletWindow window, final StateHolderController urlState) throws StateException { // get the selection accessor controller to set the selection mapping final SelectionAccessorFactory factory = (SelectionAccessorFactory) stateManager .getAccessorFactory(SelectionAccessorFactory.class ); final SelectionAccessorController selCtrl = factory .getSelectionAccessorController(urlState); try { // set the mapping which maps the current state to our portlet window selCtrl.setSelectionMapping(selCtrl.getSelection() , window.getObjectID()); } finally { // release the selection controller selCtrl.dispose(); } } /** * Helper method which sets an action into the given URL-specific state. */ protected void setState(final PortletStateManager stateManager, final PortletWindow window, final StateHolderController urlState, final PortletMode mode, final WindowState winState, final Map params) throws StateException { // get the portlet accessor controller final PortletAccessorController portletCtrl = stateManager.getPortletAccessorController(urlState ); try { // set portlet mode (if any) if (mode != null) { portletCtrl.setPortletMode(mode); } // set window state (if any) if (winState != null) { portletCtrl.setWindowState(winState); } // set render /action parameters (if any) if (params != null && !params.isEmpty()) { portletCtrl.getParameters().putAll(params); } } finally { // release portlet accessor controller portletCtrl.dispose(); } } /** * Helper method which creates a new Single Portlet Refresh render URL. */ protected EngineURL createRenderURL(final PortletStateManager stateManager, final PortletWindow window, final Map renderParams, final PortletMode mode, final WindowState winState) throws StateException { // get the URL factory final URLFactory urlFactory = stateManager.getURLFactory(); // get a new EngineURL object from the factory final EngineURL url = urlFactory.newURL(null); // get the URL-specific state final StateHolderController state = url.getState(); // make the URL a single portlet refresh URL setSelectionMapping(stateManager, window, state); // set the render state setState(stateManager, window, state, mode, winState, renderParams); // release the URL factory urlFactory.dispose(); // return the URL return url; } /** * Helper method which sets an action into the given URL-specific state. */ protected void setAction(final PortletStateManager stateManager, final PortletWindow window, final StateHolderController urlState) throws StateException { // get the target accessor controller to set the action final PortletTargetAccessorController targetCtrl = stateManager .getPortletTargetAccessorController(urlState); try { // set the action to our portlet window targetCtrl.setActionTarget(window.getObjectID()); } finally { // release the target controller targetCtrl.dispose(); } } /** * Helper method which creates a new Single Portlet Refresh action URL. */ protected EngineURL createActionURL(final PortletStateManager stateManager, final PortletWindow window, final Map actionParams) throws StateException { // get the URL factory final URLFactory urlFactory = stateManager.getURLFactory(); // get a new EngineURL object from the factory final EngineURL url = urlFactory.newURL(null); // get the URL-specific state final StateHolderController state = url.getState(); // make the URL a single portlet refresh URL setSelectionMapping(stateManager, window, state); // set the portlet action setAction(stateManager, window, state); // set the action parameters setState(stateManager, window, state, null, null, actionParams); // release the URL factory urlFactory.dispose(); // return the URL return url; } /** * Serve up the edit mode. * * @see javax.portlet.GenericPortlet#doEdit(javax.portlet. RenderRequest, javax.portlet.RenderResponse) */ public void doEdit(RenderRequest request, RenderResponse response) throws PortletException, IOException { // Set the MIME type for the render response response.setContentType(request.getResponseContent Type()); // Check if portlet session exists SinglePortletRefreshSessionBean sessionBean = getSessionBean(request); if( sessionBean==null ) { response.getWriter().println(" NO PORTLET SESSION YET "); return; } // Invoke the JSP to render PortletRequestDispatcher rd = getPortletContext().getRequestDispatcher(getJspFil ePath(request, EDIT_JSP)); rd.include(request,response); } /** * Serve up the help mode. * * @see javax.portlet.GenericPortlet#doHelp(javax.portlet. RenderRequest, javax.portlet.RenderResponse) */ protected void doHelp(RenderRequest request, RenderResponse response) throws PortletException, IOException { // Set the MIME type for the render response response.setContentType(request.getResponseContent Type()); // Invoke the JSP to render PortletRequestDispatcher rd = getPortletContext().getRequestDispatcher(getJspFil ePath(request, HELP_JSP)); rd.include(request,response); } /** * Process an action request. * * @see javax.portlet.Portlet#processAction(javax.portlet. ActionRequest, javax.portlet.ActionResponse) */ public void processAction(ActionRequest request, ActionResponse response) throws PortletException, java.io.IOException { System.err.println("executed!"); if( request.getParameter(FORM_SUBMIT) != null ) { // Set form text in the session bean SinglePortletRefreshSessionBean sessionBean = getSessionBean(request); if( sessionBean != null ) sessionBean.setFormText(request.getParameter(FORM_ TEXT)); } if( request.getParameter(EDIT_SUBMIT) != null ) { PortletPreferences prefs = request.getPreferences(); try { prefs.setValue(EDIT_KEY,request.getParameter(EDIT_ TEXT)); prefs.store(); } catch( ReadOnlyException roe ) { } catch( ValidatorException ve ) { } } } /** * Get SessionBean. * * @param request PortletRequest * @return SinglePortletRefreshSessionBean */ private static SinglePortletRefreshSessionBean getSessionBean(PortletRequest request) { PortletSession session = request.getPortletSession(); if( session == null ) return null; SinglePortletRefreshSessionBean sessionBean = (SinglePortletRefreshSessionBean)session.getAttrib ute(SESSION_BEAN); if( sessionBean == null ) { sessionBean = new SinglePortletRefreshSessionBean(); session.setAttribute(SESSION_BEAN,sessionBean); } return sessionBean; } /** * Returns JSP file path. * * @param request Render request * @param jspFile JSP file name * @return JSP file path */ private static String getJspFilePath(RenderRequest request, String jspFile) { String markup = request.getProperty("wps.markup"); if( markup == null ) markup = getMarkup(request.getResponseContentType()); return JSP_FOLDER + markup + "/" + jspFile + "." + getJspExtension(markup); } /** * Convert MIME type to markup name. * * @param contentType MIME type * @return Markup name */ private static String getMarkup(String contentType) { if( "text/vnd.wap.wml".equals(contentType) ) return "wml"; else return "html"; } /** * Returns the file extension for the JSP file * * @param markupName Markup name * @return JSP extension */ private static String getJspExtension(String markupName) { return "jsp"; } } |
|
#4
| |||
| |||
| you need some javascript in your portlet to actually call the url, so your onclick should call a javascript function that actually makes the request So like this script type="text/javascript" src=" function loadFragment(url) { new ibmsample.PortletRequest(url, refreshDOM); } function refreshDOM() { var markup = this.request.responseText; document.getElementById(" _fragment").innerHTML = markup; } Welcome! This is a sample view mode page. You have to edit this page to customize it for your own use. This is the random number = input type="button" name="Refresh" onClick=" loadFragment(' IBM Certified System Administrator -- WebSphere Portal V6.0, V5.1, V5.0 IBM Certified Solution Developer -- WebSphere Portal V5.1, v6.0 The postings on this site are my own and do not necessarily represent the positions, strategies, or opinions of IBM |
|
#5
| |||
| |||
| thanks for overview i got clear picture but little bit confusion with helper classes that you have specified below like generatingSinglePortletRefresh url that is given with renderRequest,renderResponse,nulls and another doubt is shall i need to create any extra tag like div id=" THANKS IN ADVANCE Rajasekhar Sun Certified Java Programmer 5.0 |
|
#6
| |||
| |||
| it is just a helper class to retrieve the url for a single portlet refresh, You can get it here http://www.ibm.com/support/docview.w...id=swg21265900 IBM Certified System Administrator -- WebSphere Portal V6.0, V5.1, V5.0 IBM Certified Solution Developer -- WebSphere Portal V5.1, v6.0 The postings on this site are my own and do not necessarily represent the positions, strategies, or opinions of IBM |
|
#7
| |||
| |||
| THANK YOU SO MUCH FOR YOUR SUPPORT Rajasekhar Sun Certified Java Programmer 5.0 |
|
#8
| |||
| |||
| hi jim , can you tell me single portlet refresh supported version |
|
#9
| |||
| |||
| 601 and later IBM Certified System Administrator -- WebSphere Portal V6.0, V5.1, V5.0 IBM Certified Solution Developer -- WebSphere Portal V5.1, v6.0 The postings on this site are my own and do not necessarily represent the positions, strategies, or opinions of IBM |
|
#10
| |||
| |||
| here identification helper does working well but same thing is happened here like i have created div tag for displaying response or else can we get this jspfragment (Portlet JSP) id then i can easily work it out do the need full THANKS IN ADVANCE Rajasekhar Yenduva Sun Certified Java Programmer 5.0. |
![]() |
| Thread Tools | |
| Display Modes | |
In an effort to better serve ads to our visitors, cookies are used on objectmix.com. For more information, check out our Privacy Policy.